
bin/kernel：     文件格式 elf64-littleriscv


Disassembly of section .text:

ffffffffc0200000 <kern_entry>:

    .section .text,"ax",%progbits
    .globl kern_entry
kern_entry:
    # t0 := 三级页表的虚拟地址
    lui     t0, %hi(boot_page_table_sv39)
ffffffffc0200000:	c02092b7          	lui	t0,0xc0209
    # t1 := 0xffffffff40000000 即虚实映射偏移量
    li      t1, 0xffffffffc0000000 - 0x80000000
ffffffffc0200004:	ffd0031b          	addiw	t1,zero,-3
ffffffffc0200008:	01e31313          	slli	t1,t1,0x1e
    # t0 减去虚实映射偏移量 0xffffffff40000000，变为三级页表的物理地址
    sub     t0, t0, t1
ffffffffc020000c:	406282b3          	sub	t0,t0,t1
    # t0 >>= 12，变为三级页表的物理页号
    srli    t0, t0, 12
ffffffffc0200010:	00c2d293          	srli	t0,t0,0xc

    # t1 := 8 << 60，设置 satp 的 MODE 字段为 Sv39
    li      t1, 8 << 60
ffffffffc0200014:	fff0031b          	addiw	t1,zero,-1
ffffffffc0200018:	03f31313          	slli	t1,t1,0x3f
    # 将刚才计算出的预设三级页表物理页号附加到 satp 中
    or      t0, t0, t1
ffffffffc020001c:	0062e2b3          	or	t0,t0,t1
    # 将算出的 t0(即新的MODE|页表基址物理页号) 覆盖到 satp 中
    csrw    satp, t0
ffffffffc0200020:	18029073          	csrw	satp,t0
    # 使用 sfence.vma 指令刷新 TLB
    sfence.vma
ffffffffc0200024:	12000073          	sfence.vma
    # 从此，我们给内核搭建出了一个完美的虚拟内存空间！
    #nop # 可能映射的位置有些bug。。插入一个nop
    
    # 我们在虚拟内存空间中：随意将 sp 设置为虚拟地址！
    lui sp, %hi(bootstacktop)
ffffffffc0200028:	c0209137          	lui	sp,0xc0209

    # 我们在虚拟内存空间中：随意跳转到虚拟地址！
    # 跳转到 kern_init
    lui t0, %hi(kern_init)
ffffffffc020002c:	c02002b7          	lui	t0,0xc0200
    addi t0, t0, %lo(kern_init)
ffffffffc0200030:	03628293          	addi	t0,t0,54 # ffffffffc0200036 <kern_init>
    jr t0
ffffffffc0200034:	8282                	jr	t0

ffffffffc0200036 <kern_init>:
void grade_backtrace(void);

int
kern_init(void) {
    extern char edata[], end[];
    memset(edata, 0, end - edata);
ffffffffc0200036:	0000a517          	auipc	a0,0xa
ffffffffc020003a:	02a50513          	addi	a0,a0,42 # ffffffffc020a060 <edata>
ffffffffc020003e:	00015617          	auipc	a2,0x15
ffffffffc0200042:	5c260613          	addi	a2,a2,1474 # ffffffffc0215600 <end>
kern_init(void) {
ffffffffc0200046:	1141                	addi	sp,sp,-16
    memset(edata, 0, end - edata);
ffffffffc0200048:	8e09                	sub	a2,a2,a0
ffffffffc020004a:	4581                	li	a1,0
kern_init(void) {
ffffffffc020004c:	e406                	sd	ra,8(sp)
    memset(edata, 0, end - edata);
ffffffffc020004e:	1e9040ef          	jal	ra,ffffffffc0204a36 <memset>

    cons_init();                // init the console
ffffffffc0200052:	50c000ef          	jal	ra,ffffffffc020055e <cons_init>

    const char *message = "(THU.CST) os is loading ...";
    cprintf("%s\n\n", message);
ffffffffc0200056:	00005597          	auipc	a1,0x5
ffffffffc020005a:	e4a58593          	addi	a1,a1,-438 # ffffffffc0204ea0 <etext>
ffffffffc020005e:	00005517          	auipc	a0,0x5
ffffffffc0200062:	e6250513          	addi	a0,a0,-414 # ffffffffc0204ec0 <etext+0x20>
ffffffffc0200066:	06a000ef          	jal	ra,ffffffffc02000d0 <cprintf>

    print_kerninfo();
ffffffffc020006a:	1cc000ef          	jal	ra,ffffffffc0200236 <print_kerninfo>

    // grade_backtrace();

    pmm_init();                 // init physical memory management
ffffffffc020006e:	7c1000ef          	jal	ra,ffffffffc020102e <pmm_init>

    pic_init();                 // init interrupt controller
ffffffffc0200072:	560000ef          	jal	ra,ffffffffc02005d2 <pic_init>
    idt_init();                 // init interrupt descriptor table
ffffffffc0200076:	5dc000ef          	jal	ra,ffffffffc0200652 <idt_init>

    vmm_init();                 // init virtual memory management
ffffffffc020007a:	4af010ef          	jal	ra,ffffffffc0201d28 <vmm_init>
    proc_init();                // init process table
ffffffffc020007e:	63e040ef          	jal	ra,ffffffffc02046bc <proc_init>
    
    ide_init();                 // init ide devices
ffffffffc0200082:	42e000ef          	jal	ra,ffffffffc02004b0 <ide_init>
    swap_init();                // init swap
ffffffffc0200086:	2f0020ef          	jal	ra,ffffffffc0202376 <swap_init>

    clock_init();               // init clock interrupt
ffffffffc020008a:	47e000ef          	jal	ra,ffffffffc0200508 <clock_init>
    intr_enable();              // enable irq interrupt
ffffffffc020008e:	546000ef          	jal	ra,ffffffffc02005d4 <intr_enable>

    cpu_idle();                 // run idle process
ffffffffc0200092:	01f040ef          	jal	ra,ffffffffc02048b0 <cpu_idle>

ffffffffc0200096 <cputch>:
/* *
 * cputch - writes a single character @c to stdout, and it will
 * increace the value of counter pointed by @cnt.
 * */
static void
cputch(int c, int *cnt) {
ffffffffc0200096:	1141                	addi	sp,sp,-16
ffffffffc0200098:	e022                	sd	s0,0(sp)
ffffffffc020009a:	e406                	sd	ra,8(sp)
ffffffffc020009c:	842e                	mv	s0,a1
    cons_putc(c);
ffffffffc020009e:	4c2000ef          	jal	ra,ffffffffc0200560 <cons_putc>
    (*cnt) ++;
ffffffffc02000a2:	401c                	lw	a5,0(s0)
}
ffffffffc02000a4:	60a2                	ld	ra,8(sp)
    (*cnt) ++;
ffffffffc02000a6:	2785                	addiw	a5,a5,1
ffffffffc02000a8:	c01c                	sw	a5,0(s0)
}
ffffffffc02000aa:	6402                	ld	s0,0(sp)
ffffffffc02000ac:	0141                	addi	sp,sp,16
ffffffffc02000ae:	8082                	ret

ffffffffc02000b0 <vcprintf>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want cprintf() instead.
 * */
int
vcprintf(const char *fmt, va_list ap) {
ffffffffc02000b0:	1101                	addi	sp,sp,-32
    int cnt = 0;
    vprintfmt((void*)cputch, &cnt, fmt, ap);
ffffffffc02000b2:	86ae                	mv	a3,a1
ffffffffc02000b4:	862a                	mv	a2,a0
ffffffffc02000b6:	006c                	addi	a1,sp,12
ffffffffc02000b8:	00000517          	auipc	a0,0x0
ffffffffc02000bc:	fde50513          	addi	a0,a0,-34 # ffffffffc0200096 <cputch>
vcprintf(const char *fmt, va_list ap) {
ffffffffc02000c0:	ec06                	sd	ra,24(sp)
    int cnt = 0;
ffffffffc02000c2:	c602                	sw	zero,12(sp)
    vprintfmt((void*)cputch, &cnt, fmt, ap);
ffffffffc02000c4:	239040ef          	jal	ra,ffffffffc0204afc <vprintfmt>
    return cnt;
}
ffffffffc02000c8:	60e2                	ld	ra,24(sp)
ffffffffc02000ca:	4532                	lw	a0,12(sp)
ffffffffc02000cc:	6105                	addi	sp,sp,32
ffffffffc02000ce:	8082                	ret

ffffffffc02000d0 <cprintf>:
 *
 * The return value is the number of characters which would be
 * written to stdout.
 * */
int
cprintf(const char *fmt, ...) {
ffffffffc02000d0:	711d                	addi	sp,sp,-96
    va_list ap;
    int cnt;
    va_start(ap, fmt);
ffffffffc02000d2:	02810313          	addi	t1,sp,40 # ffffffffc0209028 <boot_page_table_sv39+0x28>
cprintf(const char *fmt, ...) {
ffffffffc02000d6:	f42e                	sd	a1,40(sp)
ffffffffc02000d8:	f832                	sd	a2,48(sp)
ffffffffc02000da:	fc36                	sd	a3,56(sp)
    vprintfmt((void*)cputch, &cnt, fmt, ap);
ffffffffc02000dc:	862a                	mv	a2,a0
ffffffffc02000de:	004c                	addi	a1,sp,4
ffffffffc02000e0:	00000517          	auipc	a0,0x0
ffffffffc02000e4:	fb650513          	addi	a0,a0,-74 # ffffffffc0200096 <cputch>
ffffffffc02000e8:	869a                	mv	a3,t1
cprintf(const char *fmt, ...) {
ffffffffc02000ea:	ec06                	sd	ra,24(sp)
ffffffffc02000ec:	e0ba                	sd	a4,64(sp)
ffffffffc02000ee:	e4be                	sd	a5,72(sp)
ffffffffc02000f0:	e8c2                	sd	a6,80(sp)
ffffffffc02000f2:	ecc6                	sd	a7,88(sp)
    va_start(ap, fmt);
ffffffffc02000f4:	e41a                	sd	t1,8(sp)
    int cnt = 0;
ffffffffc02000f6:	c202                	sw	zero,4(sp)
    vprintfmt((void*)cputch, &cnt, fmt, ap);
ffffffffc02000f8:	205040ef          	jal	ra,ffffffffc0204afc <vprintfmt>
    cnt = vcprintf(fmt, ap);
    va_end(ap);
    return cnt;
}
ffffffffc02000fc:	60e2                	ld	ra,24(sp)
ffffffffc02000fe:	4512                	lw	a0,4(sp)
ffffffffc0200100:	6125                	addi	sp,sp,96
ffffffffc0200102:	8082                	ret

ffffffffc0200104 <cputchar>:

/* cputchar - writes a single character to stdout */
void
cputchar(int c) {
    cons_putc(c);
ffffffffc0200104:	45c0006f          	j	ffffffffc0200560 <cons_putc>

ffffffffc0200108 <getchar>:
    return cnt;
}

/* getchar - reads a single non-zero character from stdin */
int
getchar(void) {
ffffffffc0200108:	1141                	addi	sp,sp,-16
ffffffffc020010a:	e406                	sd	ra,8(sp)
    int c;
    while ((c = cons_getc()) == 0)
ffffffffc020010c:	48a000ef          	jal	ra,ffffffffc0200596 <cons_getc>
ffffffffc0200110:	dd75                	beqz	a0,ffffffffc020010c <getchar+0x4>
        /* do nothing */;
    return c;
}
ffffffffc0200112:	60a2                	ld	ra,8(sp)
ffffffffc0200114:	0141                	addi	sp,sp,16
ffffffffc0200116:	8082                	ret

ffffffffc0200118 <readline>:
 * The readline() function returns the text of the line read. If some errors
 * are happened, NULL is returned. The return value is a global variable,
 * thus it should be copied before it is used.
 * */
char *
readline(const char *prompt) {
ffffffffc0200118:	715d                	addi	sp,sp,-80
ffffffffc020011a:	e486                	sd	ra,72(sp)
ffffffffc020011c:	e0a2                	sd	s0,64(sp)
ffffffffc020011e:	fc26                	sd	s1,56(sp)
ffffffffc0200120:	f84a                	sd	s2,48(sp)
ffffffffc0200122:	f44e                	sd	s3,40(sp)
ffffffffc0200124:	f052                	sd	s4,32(sp)
ffffffffc0200126:	ec56                	sd	s5,24(sp)
ffffffffc0200128:	e85a                	sd	s6,16(sp)
ffffffffc020012a:	e45e                	sd	s7,8(sp)
    if (prompt != NULL) {
ffffffffc020012c:	c901                	beqz	a0,ffffffffc020013c <readline+0x24>
        cprintf("%s", prompt);
ffffffffc020012e:	85aa                	mv	a1,a0
ffffffffc0200130:	00005517          	auipc	a0,0x5
ffffffffc0200134:	d9850513          	addi	a0,a0,-616 # ffffffffc0204ec8 <etext+0x28>
ffffffffc0200138:	f99ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
readline(const char *prompt) {
ffffffffc020013c:	4481                	li	s1,0
    while (1) {
        c = getchar();
        if (c < 0) {
            return NULL;
        }
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc020013e:	497d                	li	s2,31
            cputchar(c);
            buf[i ++] = c;
        }
        else if (c == '\b' && i > 0) {
ffffffffc0200140:	49a1                	li	s3,8
            cputchar(c);
            i --;
        }
        else if (c == '\n' || c == '\r') {
ffffffffc0200142:	4aa9                	li	s5,10
ffffffffc0200144:	4b35                	li	s6,13
            buf[i ++] = c;
ffffffffc0200146:	0000ab97          	auipc	s7,0xa
ffffffffc020014a:	f1ab8b93          	addi	s7,s7,-230 # ffffffffc020a060 <edata>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc020014e:	3fe00a13          	li	s4,1022
        c = getchar();
ffffffffc0200152:	fb7ff0ef          	jal	ra,ffffffffc0200108 <getchar>
ffffffffc0200156:	842a                	mv	s0,a0
        if (c < 0) {
ffffffffc0200158:	00054b63          	bltz	a0,ffffffffc020016e <readline+0x56>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc020015c:	00a95b63          	ble	a0,s2,ffffffffc0200172 <readline+0x5a>
ffffffffc0200160:	029a5463          	ble	s1,s4,ffffffffc0200188 <readline+0x70>
        c = getchar();
ffffffffc0200164:	fa5ff0ef          	jal	ra,ffffffffc0200108 <getchar>
ffffffffc0200168:	842a                	mv	s0,a0
        if (c < 0) {
ffffffffc020016a:	fe0559e3          	bgez	a0,ffffffffc020015c <readline+0x44>
            return NULL;
ffffffffc020016e:	4501                	li	a0,0
ffffffffc0200170:	a099                	j	ffffffffc02001b6 <readline+0x9e>
        else if (c == '\b' && i > 0) {
ffffffffc0200172:	03341463          	bne	s0,s3,ffffffffc020019a <readline+0x82>
ffffffffc0200176:	e8b9                	bnez	s1,ffffffffc02001cc <readline+0xb4>
        c = getchar();
ffffffffc0200178:	f91ff0ef          	jal	ra,ffffffffc0200108 <getchar>
ffffffffc020017c:	842a                	mv	s0,a0
        if (c < 0) {
ffffffffc020017e:	fe0548e3          	bltz	a0,ffffffffc020016e <readline+0x56>
        else if (c >= ' ' && i < BUFSIZE - 1) {
ffffffffc0200182:	fea958e3          	ble	a0,s2,ffffffffc0200172 <readline+0x5a>
ffffffffc0200186:	4481                	li	s1,0
            cputchar(c);
ffffffffc0200188:	8522                	mv	a0,s0
ffffffffc020018a:	f7bff0ef          	jal	ra,ffffffffc0200104 <cputchar>
            buf[i ++] = c;
ffffffffc020018e:	009b87b3          	add	a5,s7,s1
ffffffffc0200192:	00878023          	sb	s0,0(a5)
ffffffffc0200196:	2485                	addiw	s1,s1,1
ffffffffc0200198:	bf6d                	j	ffffffffc0200152 <readline+0x3a>
        else if (c == '\n' || c == '\r') {
ffffffffc020019a:	01540463          	beq	s0,s5,ffffffffc02001a2 <readline+0x8a>
ffffffffc020019e:	fb641ae3          	bne	s0,s6,ffffffffc0200152 <readline+0x3a>
            cputchar(c);
ffffffffc02001a2:	8522                	mv	a0,s0
ffffffffc02001a4:	f61ff0ef          	jal	ra,ffffffffc0200104 <cputchar>
            buf[i] = '\0';
ffffffffc02001a8:	0000a517          	auipc	a0,0xa
ffffffffc02001ac:	eb850513          	addi	a0,a0,-328 # ffffffffc020a060 <edata>
ffffffffc02001b0:	94aa                	add	s1,s1,a0
ffffffffc02001b2:	00048023          	sb	zero,0(s1)
            return buf;
        }
    }
}
ffffffffc02001b6:	60a6                	ld	ra,72(sp)
ffffffffc02001b8:	6406                	ld	s0,64(sp)
ffffffffc02001ba:	74e2                	ld	s1,56(sp)
ffffffffc02001bc:	7942                	ld	s2,48(sp)
ffffffffc02001be:	79a2                	ld	s3,40(sp)
ffffffffc02001c0:	7a02                	ld	s4,32(sp)
ffffffffc02001c2:	6ae2                	ld	s5,24(sp)
ffffffffc02001c4:	6b42                	ld	s6,16(sp)
ffffffffc02001c6:	6ba2                	ld	s7,8(sp)
ffffffffc02001c8:	6161                	addi	sp,sp,80
ffffffffc02001ca:	8082                	ret
            cputchar(c);
ffffffffc02001cc:	4521                	li	a0,8
ffffffffc02001ce:	f37ff0ef          	jal	ra,ffffffffc0200104 <cputchar>
            i --;
ffffffffc02001d2:	34fd                	addiw	s1,s1,-1
ffffffffc02001d4:	bfbd                	j	ffffffffc0200152 <readline+0x3a>

ffffffffc02001d6 <__panic>:
 * __panic - __panic is called on unresolvable fatal errors. it prints
 * "panic: 'message'", and then enters the kernel monitor.
 * */
void
__panic(const char *file, int line, const char *fmt, ...) {
    if (is_panic) {
ffffffffc02001d6:	00015317          	auipc	t1,0x15
ffffffffc02001da:	29a30313          	addi	t1,t1,666 # ffffffffc0215470 <is_panic>
ffffffffc02001de:	00032303          	lw	t1,0(t1)
__panic(const char *file, int line, const char *fmt, ...) {
ffffffffc02001e2:	715d                	addi	sp,sp,-80
ffffffffc02001e4:	ec06                	sd	ra,24(sp)
ffffffffc02001e6:	e822                	sd	s0,16(sp)
ffffffffc02001e8:	f436                	sd	a3,40(sp)
ffffffffc02001ea:	f83a                	sd	a4,48(sp)
ffffffffc02001ec:	fc3e                	sd	a5,56(sp)
ffffffffc02001ee:	e0c2                	sd	a6,64(sp)
ffffffffc02001f0:	e4c6                	sd	a7,72(sp)
    if (is_panic) {
ffffffffc02001f2:	02031c63          	bnez	t1,ffffffffc020022a <__panic+0x54>
        goto panic_dead;
    }
    is_panic = 1;
ffffffffc02001f6:	4785                	li	a5,1
ffffffffc02001f8:	8432                	mv	s0,a2
ffffffffc02001fa:	00015717          	auipc	a4,0x15
ffffffffc02001fe:	26f72b23          	sw	a5,630(a4) # ffffffffc0215470 <is_panic>

    // print the 'message'
    va_list ap;
    va_start(ap, fmt);
    cprintf("kernel panic at %s:%d:\n    ", file, line);
ffffffffc0200202:	862e                	mv	a2,a1
    va_start(ap, fmt);
ffffffffc0200204:	103c                	addi	a5,sp,40
    cprintf("kernel panic at %s:%d:\n    ", file, line);
ffffffffc0200206:	85aa                	mv	a1,a0
ffffffffc0200208:	00005517          	auipc	a0,0x5
ffffffffc020020c:	cc850513          	addi	a0,a0,-824 # ffffffffc0204ed0 <etext+0x30>
    va_start(ap, fmt);
ffffffffc0200210:	e43e                	sd	a5,8(sp)
    cprintf("kernel panic at %s:%d:\n    ", file, line);
ffffffffc0200212:	ebfff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    vcprintf(fmt, ap);
ffffffffc0200216:	65a2                	ld	a1,8(sp)
ffffffffc0200218:	8522                	mv	a0,s0
ffffffffc020021a:	e97ff0ef          	jal	ra,ffffffffc02000b0 <vcprintf>
    cprintf("\n");
ffffffffc020021e:	00006517          	auipc	a0,0x6
ffffffffc0200222:	a6a50513          	addi	a0,a0,-1430 # ffffffffc0205c88 <commands+0xc98>
ffffffffc0200226:	eabff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    va_end(ap);

panic_dead:
    intr_disable();
ffffffffc020022a:	3b0000ef          	jal	ra,ffffffffc02005da <intr_disable>
    while (1) {
        kmonitor(NULL);
ffffffffc020022e:	4501                	li	a0,0
ffffffffc0200230:	132000ef          	jal	ra,ffffffffc0200362 <kmonitor>
ffffffffc0200234:	bfed                	j	ffffffffc020022e <__panic+0x58>

ffffffffc0200236 <print_kerninfo>:
/* *
 * print_kerninfo - print the information about kernel, including the location
 * of kernel entry, the start addresses of data and text segements, the start
 * address of free memory and how many memory that kernel has used.
 * */
void print_kerninfo(void) {
ffffffffc0200236:	1141                	addi	sp,sp,-16
    extern char etext[], edata[], end[], kern_init[];
    cprintf("Special kernel symbols:\n");
ffffffffc0200238:	00005517          	auipc	a0,0x5
ffffffffc020023c:	ce850513          	addi	a0,a0,-792 # ffffffffc0204f20 <etext+0x80>
void print_kerninfo(void) {
ffffffffc0200240:	e406                	sd	ra,8(sp)
    cprintf("Special kernel symbols:\n");
ffffffffc0200242:	e8fff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  entry  0x%08x (virtual)\n", kern_init);
ffffffffc0200246:	00000597          	auipc	a1,0x0
ffffffffc020024a:	df058593          	addi	a1,a1,-528 # ffffffffc0200036 <kern_init>
ffffffffc020024e:	00005517          	auipc	a0,0x5
ffffffffc0200252:	cf250513          	addi	a0,a0,-782 # ffffffffc0204f40 <etext+0xa0>
ffffffffc0200256:	e7bff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  etext  0x%08x (virtual)\n", etext);
ffffffffc020025a:	00005597          	auipc	a1,0x5
ffffffffc020025e:	c4658593          	addi	a1,a1,-954 # ffffffffc0204ea0 <etext>
ffffffffc0200262:	00005517          	auipc	a0,0x5
ffffffffc0200266:	cfe50513          	addi	a0,a0,-770 # ffffffffc0204f60 <etext+0xc0>
ffffffffc020026a:	e67ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  edata  0x%08x (virtual)\n", edata);
ffffffffc020026e:	0000a597          	auipc	a1,0xa
ffffffffc0200272:	df258593          	addi	a1,a1,-526 # ffffffffc020a060 <edata>
ffffffffc0200276:	00005517          	auipc	a0,0x5
ffffffffc020027a:	d0a50513          	addi	a0,a0,-758 # ffffffffc0204f80 <etext+0xe0>
ffffffffc020027e:	e53ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  end    0x%08x (virtual)\n", end);
ffffffffc0200282:	00015597          	auipc	a1,0x15
ffffffffc0200286:	37e58593          	addi	a1,a1,894 # ffffffffc0215600 <end>
ffffffffc020028a:	00005517          	auipc	a0,0x5
ffffffffc020028e:	d1650513          	addi	a0,a0,-746 # ffffffffc0204fa0 <etext+0x100>
ffffffffc0200292:	e3fff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("Kernel executable memory footprint: %dKB\n",
            (end - kern_init + 1023) / 1024);
ffffffffc0200296:	00015597          	auipc	a1,0x15
ffffffffc020029a:	76958593          	addi	a1,a1,1897 # ffffffffc02159ff <end+0x3ff>
ffffffffc020029e:	00000797          	auipc	a5,0x0
ffffffffc02002a2:	d9878793          	addi	a5,a5,-616 # ffffffffc0200036 <kern_init>
ffffffffc02002a6:	40f587b3          	sub	a5,a1,a5
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc02002aa:	43f7d593          	srai	a1,a5,0x3f
}
ffffffffc02002ae:	60a2                	ld	ra,8(sp)
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc02002b0:	3ff5f593          	andi	a1,a1,1023
ffffffffc02002b4:	95be                	add	a1,a1,a5
ffffffffc02002b6:	85a9                	srai	a1,a1,0xa
ffffffffc02002b8:	00005517          	auipc	a0,0x5
ffffffffc02002bc:	d0850513          	addi	a0,a0,-760 # ffffffffc0204fc0 <etext+0x120>
}
ffffffffc02002c0:	0141                	addi	sp,sp,16
    cprintf("Kernel executable memory footprint: %dKB\n",
ffffffffc02002c2:	e0fff06f          	j	ffffffffc02000d0 <cprintf>

ffffffffc02002c6 <print_stackframe>:
 * Note that, the length of ebp-chain is limited. In boot/bootasm.S, before
 * jumping
 * to the kernel entry, the value of ebp has been set to zero, that's the
 * boundary.
 * */
void print_stackframe(void) {
ffffffffc02002c6:	1141                	addi	sp,sp,-16
    panic("Not Implemented!");
ffffffffc02002c8:	00005617          	auipc	a2,0x5
ffffffffc02002cc:	c2860613          	addi	a2,a2,-984 # ffffffffc0204ef0 <etext+0x50>
ffffffffc02002d0:	04d00593          	li	a1,77
ffffffffc02002d4:	00005517          	auipc	a0,0x5
ffffffffc02002d8:	c3450513          	addi	a0,a0,-972 # ffffffffc0204f08 <etext+0x68>
void print_stackframe(void) {
ffffffffc02002dc:	e406                	sd	ra,8(sp)
    panic("Not Implemented!");
ffffffffc02002de:	ef9ff0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc02002e2 <mon_help>:
    }
}

/* mon_help - print the information about mon_* functions */
int
mon_help(int argc, char **argv, struct trapframe *tf) {
ffffffffc02002e2:	1141                	addi	sp,sp,-16
    int i;
    for (i = 0; i < NCOMMANDS; i ++) {
        cprintf("%s - %s\n", commands[i].name, commands[i].desc);
ffffffffc02002e4:	00005617          	auipc	a2,0x5
ffffffffc02002e8:	dec60613          	addi	a2,a2,-532 # ffffffffc02050d0 <commands+0xe0>
ffffffffc02002ec:	00005597          	auipc	a1,0x5
ffffffffc02002f0:	e0458593          	addi	a1,a1,-508 # ffffffffc02050f0 <commands+0x100>
ffffffffc02002f4:	00005517          	auipc	a0,0x5
ffffffffc02002f8:	e0450513          	addi	a0,a0,-508 # ffffffffc02050f8 <commands+0x108>
mon_help(int argc, char **argv, struct trapframe *tf) {
ffffffffc02002fc:	e406                	sd	ra,8(sp)
        cprintf("%s - %s\n", commands[i].name, commands[i].desc);
ffffffffc02002fe:	dd3ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
ffffffffc0200302:	00005617          	auipc	a2,0x5
ffffffffc0200306:	e0660613          	addi	a2,a2,-506 # ffffffffc0205108 <commands+0x118>
ffffffffc020030a:	00005597          	auipc	a1,0x5
ffffffffc020030e:	e2658593          	addi	a1,a1,-474 # ffffffffc0205130 <commands+0x140>
ffffffffc0200312:	00005517          	auipc	a0,0x5
ffffffffc0200316:	de650513          	addi	a0,a0,-538 # ffffffffc02050f8 <commands+0x108>
ffffffffc020031a:	db7ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
ffffffffc020031e:	00005617          	auipc	a2,0x5
ffffffffc0200322:	e2260613          	addi	a2,a2,-478 # ffffffffc0205140 <commands+0x150>
ffffffffc0200326:	00005597          	auipc	a1,0x5
ffffffffc020032a:	e3a58593          	addi	a1,a1,-454 # ffffffffc0205160 <commands+0x170>
ffffffffc020032e:	00005517          	auipc	a0,0x5
ffffffffc0200332:	dca50513          	addi	a0,a0,-566 # ffffffffc02050f8 <commands+0x108>
ffffffffc0200336:	d9bff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    }
    return 0;
}
ffffffffc020033a:	60a2                	ld	ra,8(sp)
ffffffffc020033c:	4501                	li	a0,0
ffffffffc020033e:	0141                	addi	sp,sp,16
ffffffffc0200340:	8082                	ret

ffffffffc0200342 <mon_kerninfo>:
/* *
 * mon_kerninfo - call print_kerninfo in kern/debug/kdebug.c to
 * print the memory occupancy in kernel.
 * */
int
mon_kerninfo(int argc, char **argv, struct trapframe *tf) {
ffffffffc0200342:	1141                	addi	sp,sp,-16
ffffffffc0200344:	e406                	sd	ra,8(sp)
    print_kerninfo();
ffffffffc0200346:	ef1ff0ef          	jal	ra,ffffffffc0200236 <print_kerninfo>
    return 0;
}
ffffffffc020034a:	60a2                	ld	ra,8(sp)
ffffffffc020034c:	4501                	li	a0,0
ffffffffc020034e:	0141                	addi	sp,sp,16
ffffffffc0200350:	8082                	ret

ffffffffc0200352 <mon_backtrace>:
/* *
 * mon_backtrace - call print_stackframe in kern/debug/kdebug.c to
 * print a backtrace of the stack.
 * */
int
mon_backtrace(int argc, char **argv, struct trapframe *tf) {
ffffffffc0200352:	1141                	addi	sp,sp,-16
ffffffffc0200354:	e406                	sd	ra,8(sp)
    print_stackframe();
ffffffffc0200356:	f71ff0ef          	jal	ra,ffffffffc02002c6 <print_stackframe>
    return 0;
}
ffffffffc020035a:	60a2                	ld	ra,8(sp)
ffffffffc020035c:	4501                	li	a0,0
ffffffffc020035e:	0141                	addi	sp,sp,16
ffffffffc0200360:	8082                	ret

ffffffffc0200362 <kmonitor>:
kmonitor(struct trapframe *tf) {
ffffffffc0200362:	7115                	addi	sp,sp,-224
ffffffffc0200364:	e962                	sd	s8,144(sp)
ffffffffc0200366:	8c2a                	mv	s8,a0
    cprintf("Welcome to the kernel debug monitor!!\n");
ffffffffc0200368:	00005517          	auipc	a0,0x5
ffffffffc020036c:	cd050513          	addi	a0,a0,-816 # ffffffffc0205038 <commands+0x48>
kmonitor(struct trapframe *tf) {
ffffffffc0200370:	ed86                	sd	ra,216(sp)
ffffffffc0200372:	e9a2                	sd	s0,208(sp)
ffffffffc0200374:	e5a6                	sd	s1,200(sp)
ffffffffc0200376:	e1ca                	sd	s2,192(sp)
ffffffffc0200378:	fd4e                	sd	s3,184(sp)
ffffffffc020037a:	f952                	sd	s4,176(sp)
ffffffffc020037c:	f556                	sd	s5,168(sp)
ffffffffc020037e:	f15a                	sd	s6,160(sp)
ffffffffc0200380:	ed5e                	sd	s7,152(sp)
ffffffffc0200382:	e566                	sd	s9,136(sp)
ffffffffc0200384:	e16a                	sd	s10,128(sp)
    cprintf("Welcome to the kernel debug monitor!!\n");
ffffffffc0200386:	d4bff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("Type 'help' for a list of commands.\n");
ffffffffc020038a:	00005517          	auipc	a0,0x5
ffffffffc020038e:	cd650513          	addi	a0,a0,-810 # ffffffffc0205060 <commands+0x70>
ffffffffc0200392:	d3fff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    if (tf != NULL) {
ffffffffc0200396:	000c0563          	beqz	s8,ffffffffc02003a0 <kmonitor+0x3e>
        print_trapframe(tf);
ffffffffc020039a:	8562                	mv	a0,s8
ffffffffc020039c:	49e000ef          	jal	ra,ffffffffc020083a <print_trapframe>
#endif
}

static inline void sbi_shutdown(void)
{
	SBI_CALL_0(SBI_SHUTDOWN);
ffffffffc02003a0:	4501                	li	a0,0
ffffffffc02003a2:	4581                	li	a1,0
ffffffffc02003a4:	4601                	li	a2,0
ffffffffc02003a6:	48a1                	li	a7,8
ffffffffc02003a8:	00000073          	ecall
ffffffffc02003ac:	00005c97          	auipc	s9,0x5
ffffffffc02003b0:	c44c8c93          	addi	s9,s9,-956 # ffffffffc0204ff0 <commands>
        if ((buf = readline("K> ")) != NULL) {
ffffffffc02003b4:	00005997          	auipc	s3,0x5
ffffffffc02003b8:	cd498993          	addi	s3,s3,-812 # ffffffffc0205088 <commands+0x98>
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc02003bc:	00005917          	auipc	s2,0x5
ffffffffc02003c0:	cd490913          	addi	s2,s2,-812 # ffffffffc0205090 <commands+0xa0>
        if (argc == MAXARGS - 1) {
ffffffffc02003c4:	4a3d                	li	s4,15
            cprintf("Too many arguments (max %d).\n", MAXARGS);
ffffffffc02003c6:	00005b17          	auipc	s6,0x5
ffffffffc02003ca:	cd2b0b13          	addi	s6,s6,-814 # ffffffffc0205098 <commands+0xa8>
    if (argc == 0) {
ffffffffc02003ce:	00005a97          	auipc	s5,0x5
ffffffffc02003d2:	d22a8a93          	addi	s5,s5,-734 # ffffffffc02050f0 <commands+0x100>
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc02003d6:	4b8d                	li	s7,3
        if ((buf = readline("K> ")) != NULL) {
ffffffffc02003d8:	854e                	mv	a0,s3
ffffffffc02003da:	d3fff0ef          	jal	ra,ffffffffc0200118 <readline>
ffffffffc02003de:	842a                	mv	s0,a0
ffffffffc02003e0:	dd65                	beqz	a0,ffffffffc02003d8 <kmonitor+0x76>
ffffffffc02003e2:	00054583          	lbu	a1,0(a0)
    int argc = 0;
ffffffffc02003e6:	4481                	li	s1,0
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc02003e8:	c999                	beqz	a1,ffffffffc02003fe <kmonitor+0x9c>
ffffffffc02003ea:	854a                	mv	a0,s2
ffffffffc02003ec:	62c040ef          	jal	ra,ffffffffc0204a18 <strchr>
ffffffffc02003f0:	c925                	beqz	a0,ffffffffc0200460 <kmonitor+0xfe>
            *buf ++ = '\0';
ffffffffc02003f2:	00144583          	lbu	a1,1(s0)
ffffffffc02003f6:	00040023          	sb	zero,0(s0)
ffffffffc02003fa:	0405                	addi	s0,s0,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
ffffffffc02003fc:	f5fd                	bnez	a1,ffffffffc02003ea <kmonitor+0x88>
    if (argc == 0) {
ffffffffc02003fe:	dce9                	beqz	s1,ffffffffc02003d8 <kmonitor+0x76>
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc0200400:	6582                	ld	a1,0(sp)
ffffffffc0200402:	00005d17          	auipc	s10,0x5
ffffffffc0200406:	beed0d13          	addi	s10,s10,-1042 # ffffffffc0204ff0 <commands>
    if (argc == 0) {
ffffffffc020040a:	8556                	mv	a0,s5
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc020040c:	4401                	li	s0,0
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc020040e:	0d61                	addi	s10,s10,24
ffffffffc0200410:	5de040ef          	jal	ra,ffffffffc02049ee <strcmp>
ffffffffc0200414:	c919                	beqz	a0,ffffffffc020042a <kmonitor+0xc8>
    for (i = 0; i < NCOMMANDS; i ++) {
ffffffffc0200416:	2405                	addiw	s0,s0,1
ffffffffc0200418:	09740463          	beq	s0,s7,ffffffffc02004a0 <kmonitor+0x13e>
ffffffffc020041c:	000d3503          	ld	a0,0(s10)
        if (strcmp(commands[i].name, argv[0]) == 0) {
ffffffffc0200420:	6582                	ld	a1,0(sp)
ffffffffc0200422:	0d61                	addi	s10,s10,24
ffffffffc0200424:	5ca040ef          	jal	ra,ffffffffc02049ee <strcmp>
ffffffffc0200428:	f57d                	bnez	a0,ffffffffc0200416 <kmonitor+0xb4>
            return commands[i].func(argc - 1, argv + 1, tf);
ffffffffc020042a:	00141793          	slli	a5,s0,0x1
ffffffffc020042e:	97a2                	add	a5,a5,s0
ffffffffc0200430:	078e                	slli	a5,a5,0x3
ffffffffc0200432:	97e6                	add	a5,a5,s9
ffffffffc0200434:	6b9c                	ld	a5,16(a5)
ffffffffc0200436:	8662                	mv	a2,s8
ffffffffc0200438:	002c                	addi	a1,sp,8
ffffffffc020043a:	fff4851b          	addiw	a0,s1,-1
ffffffffc020043e:	9782                	jalr	a5
            if (runcmd(buf, tf) < 0) {
ffffffffc0200440:	f8055ce3          	bgez	a0,ffffffffc02003d8 <kmonitor+0x76>
}
ffffffffc0200444:	60ee                	ld	ra,216(sp)
ffffffffc0200446:	644e                	ld	s0,208(sp)
ffffffffc0200448:	64ae                	ld	s1,200(sp)
ffffffffc020044a:	690e                	ld	s2,192(sp)
ffffffffc020044c:	79ea                	ld	s3,184(sp)
ffffffffc020044e:	7a4a                	ld	s4,176(sp)
ffffffffc0200450:	7aaa                	ld	s5,168(sp)
ffffffffc0200452:	7b0a                	ld	s6,160(sp)
ffffffffc0200454:	6bea                	ld	s7,152(sp)
ffffffffc0200456:	6c4a                	ld	s8,144(sp)
ffffffffc0200458:	6caa                	ld	s9,136(sp)
ffffffffc020045a:	6d0a                	ld	s10,128(sp)
ffffffffc020045c:	612d                	addi	sp,sp,224
ffffffffc020045e:	8082                	ret
        if (*buf == '\0') {
ffffffffc0200460:	00044783          	lbu	a5,0(s0)
ffffffffc0200464:	dfc9                	beqz	a5,ffffffffc02003fe <kmonitor+0x9c>
        if (argc == MAXARGS - 1) {
ffffffffc0200466:	03448863          	beq	s1,s4,ffffffffc0200496 <kmonitor+0x134>
        argv[argc ++] = buf;
ffffffffc020046a:	00349793          	slli	a5,s1,0x3
ffffffffc020046e:	0118                	addi	a4,sp,128
ffffffffc0200470:	97ba                	add	a5,a5,a4
ffffffffc0200472:	f887b023          	sd	s0,-128(a5)
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc0200476:	00044583          	lbu	a1,0(s0)
        argv[argc ++] = buf;
ffffffffc020047a:	2485                	addiw	s1,s1,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc020047c:	e591                	bnez	a1,ffffffffc0200488 <kmonitor+0x126>
ffffffffc020047e:	b749                	j	ffffffffc0200400 <kmonitor+0x9e>
            buf ++;
ffffffffc0200480:	0405                	addi	s0,s0,1
        while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
ffffffffc0200482:	00044583          	lbu	a1,0(s0)
ffffffffc0200486:	ddad                	beqz	a1,ffffffffc0200400 <kmonitor+0x9e>
ffffffffc0200488:	854a                	mv	a0,s2
ffffffffc020048a:	58e040ef          	jal	ra,ffffffffc0204a18 <strchr>
ffffffffc020048e:	d96d                	beqz	a0,ffffffffc0200480 <kmonitor+0x11e>
ffffffffc0200490:	00044583          	lbu	a1,0(s0)
ffffffffc0200494:	bf91                	j	ffffffffc02003e8 <kmonitor+0x86>
            cprintf("Too many arguments (max %d).\n", MAXARGS);
ffffffffc0200496:	45c1                	li	a1,16
ffffffffc0200498:	855a                	mv	a0,s6
ffffffffc020049a:	c37ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
ffffffffc020049e:	b7f1                	j	ffffffffc020046a <kmonitor+0x108>
    cprintf("Unknown command '%s'\n", argv[0]);
ffffffffc02004a0:	6582                	ld	a1,0(sp)
ffffffffc02004a2:	00005517          	auipc	a0,0x5
ffffffffc02004a6:	c1650513          	addi	a0,a0,-1002 # ffffffffc02050b8 <commands+0xc8>
ffffffffc02004aa:	c27ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    return 0;
ffffffffc02004ae:	b72d                	j	ffffffffc02003d8 <kmonitor+0x76>

ffffffffc02004b0 <ide_init>:
#include <stdio.h>
#include <string.h>
#include <trap.h>
#include <riscv.h>

void ide_init(void) {}
ffffffffc02004b0:	8082                	ret

ffffffffc02004b2 <ide_device_valid>:

#define MAX_IDE 2
#define MAX_DISK_NSECS 56
static char ide[MAX_DISK_NSECS * SECTSIZE];

bool ide_device_valid(unsigned short ideno) { return ideno < MAX_IDE; }
ffffffffc02004b2:	00253513          	sltiu	a0,a0,2
ffffffffc02004b6:	8082                	ret

ffffffffc02004b8 <ide_device_size>:

size_t ide_device_size(unsigned short ideno) { return MAX_DISK_NSECS; }
ffffffffc02004b8:	03800513          	li	a0,56
ffffffffc02004bc:	8082                	ret

ffffffffc02004be <ide_read_secs>:

int ide_read_secs(unsigned short ideno, uint32_t secno, void *dst,
                  size_t nsecs) {
    int iobase = secno * SECTSIZE;
    memcpy(dst, &ide[iobase], nsecs * SECTSIZE);
ffffffffc02004be:	0000a797          	auipc	a5,0xa
ffffffffc02004c2:	fa278793          	addi	a5,a5,-94 # ffffffffc020a460 <ide>
ffffffffc02004c6:	0095959b          	slliw	a1,a1,0x9
                  size_t nsecs) {
ffffffffc02004ca:	1141                	addi	sp,sp,-16
ffffffffc02004cc:	8532                	mv	a0,a2
    memcpy(dst, &ide[iobase], nsecs * SECTSIZE);
ffffffffc02004ce:	95be                	add	a1,a1,a5
ffffffffc02004d0:	00969613          	slli	a2,a3,0x9
                  size_t nsecs) {
ffffffffc02004d4:	e406                	sd	ra,8(sp)
    memcpy(dst, &ide[iobase], nsecs * SECTSIZE);
ffffffffc02004d6:	572040ef          	jal	ra,ffffffffc0204a48 <memcpy>
    return 0;
}
ffffffffc02004da:	60a2                	ld	ra,8(sp)
ffffffffc02004dc:	4501                	li	a0,0
ffffffffc02004de:	0141                	addi	sp,sp,16
ffffffffc02004e0:	8082                	ret

ffffffffc02004e2 <ide_write_secs>:

int ide_write_secs(unsigned short ideno, uint32_t secno, const void *src,
                   size_t nsecs) {
ffffffffc02004e2:	8732                	mv	a4,a2
    int iobase = secno * SECTSIZE;
    memcpy(&ide[iobase], src, nsecs * SECTSIZE);
ffffffffc02004e4:	0095979b          	slliw	a5,a1,0x9
ffffffffc02004e8:	0000a517          	auipc	a0,0xa
ffffffffc02004ec:	f7850513          	addi	a0,a0,-136 # ffffffffc020a460 <ide>
                   size_t nsecs) {
ffffffffc02004f0:	1141                	addi	sp,sp,-16
    memcpy(&ide[iobase], src, nsecs * SECTSIZE);
ffffffffc02004f2:	00969613          	slli	a2,a3,0x9
ffffffffc02004f6:	85ba                	mv	a1,a4
ffffffffc02004f8:	953e                	add	a0,a0,a5
                   size_t nsecs) {
ffffffffc02004fa:	e406                	sd	ra,8(sp)
    memcpy(&ide[iobase], src, nsecs * SECTSIZE);
ffffffffc02004fc:	54c040ef          	jal	ra,ffffffffc0204a48 <memcpy>
    return 0;
}
ffffffffc0200500:	60a2                	ld	ra,8(sp)
ffffffffc0200502:	4501                	li	a0,0
ffffffffc0200504:	0141                	addi	sp,sp,16
ffffffffc0200506:	8082                	ret

ffffffffc0200508 <clock_init>:
 * and then enable IRQ_TIMER.
 * */
void clock_init(void) {
    // divided by 500 when using Spike(2MHz)
    // divided by 100 when using QEMU(10MHz)
    timebase = 1e7 / 100;
ffffffffc0200508:	67e1                	lui	a5,0x18
ffffffffc020050a:	6a078793          	addi	a5,a5,1696 # 186a0 <BASE_ADDRESS-0xffffffffc01e7960>
ffffffffc020050e:	00015717          	auipc	a4,0x15
ffffffffc0200512:	f6f73523          	sd	a5,-150(a4) # ffffffffc0215478 <timebase>
    __asm__ __volatile__("rdtime %0" : "=r"(n));
ffffffffc0200516:	c0102573          	rdtime	a0
	SBI_CALL_1(SBI_SET_TIMER, stime_value);
ffffffffc020051a:	4581                	li	a1,0
    ticks = 0;

    cprintf("++ setup timer interrupts\n");
}

void clock_set_next_event(void) { sbi_set_timer(get_cycles() + timebase); }
ffffffffc020051c:	953e                	add	a0,a0,a5
ffffffffc020051e:	4601                	li	a2,0
ffffffffc0200520:	4881                	li	a7,0
ffffffffc0200522:	00000073          	ecall
    set_csr(sie, MIP_STIP);
ffffffffc0200526:	02000793          	li	a5,32
ffffffffc020052a:	1047a7f3          	csrrs	a5,sie,a5
    cprintf("++ setup timer interrupts\n");
ffffffffc020052e:	00005517          	auipc	a0,0x5
ffffffffc0200532:	c4250513          	addi	a0,a0,-958 # ffffffffc0205170 <commands+0x180>
    ticks = 0;
ffffffffc0200536:	00015797          	auipc	a5,0x15
ffffffffc020053a:	f807bd23          	sd	zero,-102(a5) # ffffffffc02154d0 <ticks>
    cprintf("++ setup timer interrupts\n");
ffffffffc020053e:	b93ff06f          	j	ffffffffc02000d0 <cprintf>

ffffffffc0200542 <clock_set_next_event>:
    __asm__ __volatile__("rdtime %0" : "=r"(n));
ffffffffc0200542:	c0102573          	rdtime	a0
void clock_set_next_event(void) { sbi_set_timer(get_cycles() + timebase); }
ffffffffc0200546:	00015797          	auipc	a5,0x15
ffffffffc020054a:	f3278793          	addi	a5,a5,-206 # ffffffffc0215478 <timebase>
ffffffffc020054e:	639c                	ld	a5,0(a5)
ffffffffc0200550:	4581                	li	a1,0
ffffffffc0200552:	4601                	li	a2,0
ffffffffc0200554:	953e                	add	a0,a0,a5
ffffffffc0200556:	4881                	li	a7,0
ffffffffc0200558:	00000073          	ecall
ffffffffc020055c:	8082                	ret

ffffffffc020055e <cons_init>:

/* serial_intr - try to feed input characters from serial port */
void serial_intr(void) {}

/* cons_init - initializes the console devices */
void cons_init(void) {}
ffffffffc020055e:	8082                	ret

ffffffffc0200560 <cons_putc>:
#include <defs.h>
#include <intr.h>
#include <riscv.h>

static inline bool __intr_save(void) {
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0200560:	100027f3          	csrr	a5,sstatus
ffffffffc0200564:	8b89                	andi	a5,a5,2
ffffffffc0200566:	0ff57513          	andi	a0,a0,255
ffffffffc020056a:	e799                	bnez	a5,ffffffffc0200578 <cons_putc+0x18>
	SBI_CALL_1(SBI_CONSOLE_PUTCHAR, ch);
ffffffffc020056c:	4581                	li	a1,0
ffffffffc020056e:	4601                	li	a2,0
ffffffffc0200570:	4885                	li	a7,1
ffffffffc0200572:	00000073          	ecall
    }
    return 0;
}

static inline void __intr_restore(bool flag) {
    if (flag) {
ffffffffc0200576:	8082                	ret

/* cons_putc - print a single character @c to console devices */
void cons_putc(int c) {
ffffffffc0200578:	1101                	addi	sp,sp,-32
ffffffffc020057a:	ec06                	sd	ra,24(sp)
ffffffffc020057c:	e42a                	sd	a0,8(sp)
        intr_disable();
ffffffffc020057e:	05c000ef          	jal	ra,ffffffffc02005da <intr_disable>
ffffffffc0200582:	6522                	ld	a0,8(sp)
ffffffffc0200584:	4581                	li	a1,0
ffffffffc0200586:	4601                	li	a2,0
ffffffffc0200588:	4885                	li	a7,1
ffffffffc020058a:	00000073          	ecall
    local_intr_save(intr_flag);
    {
        sbi_console_putchar((unsigned char)c);
    }
    local_intr_restore(intr_flag);
}
ffffffffc020058e:	60e2                	ld	ra,24(sp)
ffffffffc0200590:	6105                	addi	sp,sp,32
        intr_enable();
ffffffffc0200592:	0420006f          	j	ffffffffc02005d4 <intr_enable>

ffffffffc0200596 <cons_getc>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0200596:	100027f3          	csrr	a5,sstatus
ffffffffc020059a:	8b89                	andi	a5,a5,2
ffffffffc020059c:	eb89                	bnez	a5,ffffffffc02005ae <cons_getc+0x18>
	return SBI_CALL_0(SBI_CONSOLE_GETCHAR);
ffffffffc020059e:	4501                	li	a0,0
ffffffffc02005a0:	4581                	li	a1,0
ffffffffc02005a2:	4601                	li	a2,0
ffffffffc02005a4:	4889                	li	a7,2
ffffffffc02005a6:	00000073          	ecall
ffffffffc02005aa:	2501                	sext.w	a0,a0
    {
        c = sbi_console_getchar();
    }
    local_intr_restore(intr_flag);
    return c;
}
ffffffffc02005ac:	8082                	ret
int cons_getc(void) {
ffffffffc02005ae:	1101                	addi	sp,sp,-32
ffffffffc02005b0:	ec06                	sd	ra,24(sp)
        intr_disable();
ffffffffc02005b2:	028000ef          	jal	ra,ffffffffc02005da <intr_disable>
ffffffffc02005b6:	4501                	li	a0,0
ffffffffc02005b8:	4581                	li	a1,0
ffffffffc02005ba:	4601                	li	a2,0
ffffffffc02005bc:	4889                	li	a7,2
ffffffffc02005be:	00000073          	ecall
ffffffffc02005c2:	2501                	sext.w	a0,a0
ffffffffc02005c4:	e42a                	sd	a0,8(sp)
        intr_enable();
ffffffffc02005c6:	00e000ef          	jal	ra,ffffffffc02005d4 <intr_enable>
}
ffffffffc02005ca:	60e2                	ld	ra,24(sp)
ffffffffc02005cc:	6522                	ld	a0,8(sp)
ffffffffc02005ce:	6105                	addi	sp,sp,32
ffffffffc02005d0:	8082                	ret

ffffffffc02005d2 <pic_init>:
#include <picirq.h>

void pic_enable(unsigned int irq) {}

/* pic_init - initialize the 8259A interrupt controllers */
void pic_init(void) {}
ffffffffc02005d2:	8082                	ret

ffffffffc02005d4 <intr_enable>:
#include <intr.h>
#include <riscv.h>

/* intr_enable - enable irq interrupt */
void intr_enable(void) { set_csr(sstatus, SSTATUS_SIE); }
ffffffffc02005d4:	100167f3          	csrrsi	a5,sstatus,2
ffffffffc02005d8:	8082                	ret

ffffffffc02005da <intr_disable>:

/* intr_disable - disable irq interrupt */
void intr_disable(void) { clear_csr(sstatus, SSTATUS_SIE); }
ffffffffc02005da:	100177f3          	csrrci	a5,sstatus,2
ffffffffc02005de:	8082                	ret

ffffffffc02005e0 <pgfault_handler>:
    set_csr(sstatus, SSTATUS_SUM);
}

/* trap_in_kernel - test if trap happened in kernel */
bool trap_in_kernel(struct trapframe *tf) {
    return (tf->status & SSTATUS_SPP) != 0;
ffffffffc02005e0:	10053783          	ld	a5,256(a0)
    cprintf("page falut at 0x%08x: %c/%c\n", tf->badvaddr,
            trap_in_kernel(tf) ? 'K' : 'U',
            tf->cause == CAUSE_STORE_PAGE_FAULT ? 'W' : 'R');
}

static int pgfault_handler(struct trapframe *tf) {
ffffffffc02005e4:	1141                	addi	sp,sp,-16
ffffffffc02005e6:	e022                	sd	s0,0(sp)
ffffffffc02005e8:	e406                	sd	ra,8(sp)
    return (tf->status & SSTATUS_SPP) != 0;
ffffffffc02005ea:	1007f793          	andi	a5,a5,256
static int pgfault_handler(struct trapframe *tf) {
ffffffffc02005ee:	842a                	mv	s0,a0
    cprintf("page falut at 0x%08x: %c/%c\n", tf->badvaddr,
ffffffffc02005f0:	11053583          	ld	a1,272(a0)
ffffffffc02005f4:	05500613          	li	a2,85
ffffffffc02005f8:	c399                	beqz	a5,ffffffffc02005fe <pgfault_handler+0x1e>
ffffffffc02005fa:	04b00613          	li	a2,75
ffffffffc02005fe:	11843703          	ld	a4,280(s0)
ffffffffc0200602:	47bd                	li	a5,15
ffffffffc0200604:	05700693          	li	a3,87
ffffffffc0200608:	00f70463          	beq	a4,a5,ffffffffc0200610 <pgfault_handler+0x30>
ffffffffc020060c:	05200693          	li	a3,82
ffffffffc0200610:	00005517          	auipc	a0,0x5
ffffffffc0200614:	e5850513          	addi	a0,a0,-424 # ffffffffc0205468 <commands+0x478>
ffffffffc0200618:	ab9ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    extern struct mm_struct *check_mm_struct;
    print_pgfault(tf);
    if (check_mm_struct != NULL) {
ffffffffc020061c:	00015797          	auipc	a5,0x15
ffffffffc0200620:	edc78793          	addi	a5,a5,-292 # ffffffffc02154f8 <check_mm_struct>
ffffffffc0200624:	6388                	ld	a0,0(a5)
ffffffffc0200626:	c911                	beqz	a0,ffffffffc020063a <pgfault_handler+0x5a>
        return do_pgfault(check_mm_struct, tf->cause, tf->badvaddr);
ffffffffc0200628:	11043603          	ld	a2,272(s0)
ffffffffc020062c:	11842583          	lw	a1,280(s0)
    }
    panic("unhandled page fault.\n");
}
ffffffffc0200630:	6402                	ld	s0,0(sp)
ffffffffc0200632:	60a2                	ld	ra,8(sp)
ffffffffc0200634:	0141                	addi	sp,sp,16
        return do_pgfault(check_mm_struct, tf->cause, tf->badvaddr);
ffffffffc0200636:	4390106f          	j	ffffffffc020226e <do_pgfault>
    panic("unhandled page fault.\n");
ffffffffc020063a:	00005617          	auipc	a2,0x5
ffffffffc020063e:	e4e60613          	addi	a2,a2,-434 # ffffffffc0205488 <commands+0x498>
ffffffffc0200642:	06200593          	li	a1,98
ffffffffc0200646:	00005517          	auipc	a0,0x5
ffffffffc020064a:	e5a50513          	addi	a0,a0,-422 # ffffffffc02054a0 <commands+0x4b0>
ffffffffc020064e:	b89ff0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0200652 <idt_init>:
    write_csr(sscratch, 0);
ffffffffc0200652:	14005073          	csrwi	sscratch,0
    write_csr(stvec, &__alltraps);
ffffffffc0200656:	00000797          	auipc	a5,0x0
ffffffffc020065a:	48e78793          	addi	a5,a5,1166 # ffffffffc0200ae4 <__alltraps>
ffffffffc020065e:	10579073          	csrw	stvec,a5
    set_csr(sstatus, SSTATUS_SUM);
ffffffffc0200662:	000407b7          	lui	a5,0x40
ffffffffc0200666:	1007a7f3          	csrrs	a5,sstatus,a5
}
ffffffffc020066a:	8082                	ret

ffffffffc020066c <print_regs>:
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc020066c:	610c                	ld	a1,0(a0)
void print_regs(struct pushregs *gpr) {
ffffffffc020066e:	1141                	addi	sp,sp,-16
ffffffffc0200670:	e022                	sd	s0,0(sp)
ffffffffc0200672:	842a                	mv	s0,a0
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc0200674:	00005517          	auipc	a0,0x5
ffffffffc0200678:	e4450513          	addi	a0,a0,-444 # ffffffffc02054b8 <commands+0x4c8>
void print_regs(struct pushregs *gpr) {
ffffffffc020067c:	e406                	sd	ra,8(sp)
    cprintf("  zero     0x%08x\n", gpr->zero);
ffffffffc020067e:	a53ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  ra       0x%08x\n", gpr->ra);
ffffffffc0200682:	640c                	ld	a1,8(s0)
ffffffffc0200684:	00005517          	auipc	a0,0x5
ffffffffc0200688:	e4c50513          	addi	a0,a0,-436 # ffffffffc02054d0 <commands+0x4e0>
ffffffffc020068c:	a45ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  sp       0x%08x\n", gpr->sp);
ffffffffc0200690:	680c                	ld	a1,16(s0)
ffffffffc0200692:	00005517          	auipc	a0,0x5
ffffffffc0200696:	e5650513          	addi	a0,a0,-426 # ffffffffc02054e8 <commands+0x4f8>
ffffffffc020069a:	a37ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  gp       0x%08x\n", gpr->gp);
ffffffffc020069e:	6c0c                	ld	a1,24(s0)
ffffffffc02006a0:	00005517          	auipc	a0,0x5
ffffffffc02006a4:	e6050513          	addi	a0,a0,-416 # ffffffffc0205500 <commands+0x510>
ffffffffc02006a8:	a29ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  tp       0x%08x\n", gpr->tp);
ffffffffc02006ac:	700c                	ld	a1,32(s0)
ffffffffc02006ae:	00005517          	auipc	a0,0x5
ffffffffc02006b2:	e6a50513          	addi	a0,a0,-406 # ffffffffc0205518 <commands+0x528>
ffffffffc02006b6:	a1bff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  t0       0x%08x\n", gpr->t0);
ffffffffc02006ba:	740c                	ld	a1,40(s0)
ffffffffc02006bc:	00005517          	auipc	a0,0x5
ffffffffc02006c0:	e7450513          	addi	a0,a0,-396 # ffffffffc0205530 <commands+0x540>
ffffffffc02006c4:	a0dff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  t1       0x%08x\n", gpr->t1);
ffffffffc02006c8:	780c                	ld	a1,48(s0)
ffffffffc02006ca:	00005517          	auipc	a0,0x5
ffffffffc02006ce:	e7e50513          	addi	a0,a0,-386 # ffffffffc0205548 <commands+0x558>
ffffffffc02006d2:	9ffff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  t2       0x%08x\n", gpr->t2);
ffffffffc02006d6:	7c0c                	ld	a1,56(s0)
ffffffffc02006d8:	00005517          	auipc	a0,0x5
ffffffffc02006dc:	e8850513          	addi	a0,a0,-376 # ffffffffc0205560 <commands+0x570>
ffffffffc02006e0:	9f1ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s0       0x%08x\n", gpr->s0);
ffffffffc02006e4:	602c                	ld	a1,64(s0)
ffffffffc02006e6:	00005517          	auipc	a0,0x5
ffffffffc02006ea:	e9250513          	addi	a0,a0,-366 # ffffffffc0205578 <commands+0x588>
ffffffffc02006ee:	9e3ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s1       0x%08x\n", gpr->s1);
ffffffffc02006f2:	642c                	ld	a1,72(s0)
ffffffffc02006f4:	00005517          	auipc	a0,0x5
ffffffffc02006f8:	e9c50513          	addi	a0,a0,-356 # ffffffffc0205590 <commands+0x5a0>
ffffffffc02006fc:	9d5ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  a0       0x%08x\n", gpr->a0);
ffffffffc0200700:	682c                	ld	a1,80(s0)
ffffffffc0200702:	00005517          	auipc	a0,0x5
ffffffffc0200706:	ea650513          	addi	a0,a0,-346 # ffffffffc02055a8 <commands+0x5b8>
ffffffffc020070a:	9c7ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  a1       0x%08x\n", gpr->a1);
ffffffffc020070e:	6c2c                	ld	a1,88(s0)
ffffffffc0200710:	00005517          	auipc	a0,0x5
ffffffffc0200714:	eb050513          	addi	a0,a0,-336 # ffffffffc02055c0 <commands+0x5d0>
ffffffffc0200718:	9b9ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  a2       0x%08x\n", gpr->a2);
ffffffffc020071c:	702c                	ld	a1,96(s0)
ffffffffc020071e:	00005517          	auipc	a0,0x5
ffffffffc0200722:	eba50513          	addi	a0,a0,-326 # ffffffffc02055d8 <commands+0x5e8>
ffffffffc0200726:	9abff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  a3       0x%08x\n", gpr->a3);
ffffffffc020072a:	742c                	ld	a1,104(s0)
ffffffffc020072c:	00005517          	auipc	a0,0x5
ffffffffc0200730:	ec450513          	addi	a0,a0,-316 # ffffffffc02055f0 <commands+0x600>
ffffffffc0200734:	99dff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  a4       0x%08x\n", gpr->a4);
ffffffffc0200738:	782c                	ld	a1,112(s0)
ffffffffc020073a:	00005517          	auipc	a0,0x5
ffffffffc020073e:	ece50513          	addi	a0,a0,-306 # ffffffffc0205608 <commands+0x618>
ffffffffc0200742:	98fff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  a5       0x%08x\n", gpr->a5);
ffffffffc0200746:	7c2c                	ld	a1,120(s0)
ffffffffc0200748:	00005517          	auipc	a0,0x5
ffffffffc020074c:	ed850513          	addi	a0,a0,-296 # ffffffffc0205620 <commands+0x630>
ffffffffc0200750:	981ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  a6       0x%08x\n", gpr->a6);
ffffffffc0200754:	604c                	ld	a1,128(s0)
ffffffffc0200756:	00005517          	auipc	a0,0x5
ffffffffc020075a:	ee250513          	addi	a0,a0,-286 # ffffffffc0205638 <commands+0x648>
ffffffffc020075e:	973ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  a7       0x%08x\n", gpr->a7);
ffffffffc0200762:	644c                	ld	a1,136(s0)
ffffffffc0200764:	00005517          	auipc	a0,0x5
ffffffffc0200768:	eec50513          	addi	a0,a0,-276 # ffffffffc0205650 <commands+0x660>
ffffffffc020076c:	965ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s2       0x%08x\n", gpr->s2);
ffffffffc0200770:	684c                	ld	a1,144(s0)
ffffffffc0200772:	00005517          	auipc	a0,0x5
ffffffffc0200776:	ef650513          	addi	a0,a0,-266 # ffffffffc0205668 <commands+0x678>
ffffffffc020077a:	957ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s3       0x%08x\n", gpr->s3);
ffffffffc020077e:	6c4c                	ld	a1,152(s0)
ffffffffc0200780:	00005517          	auipc	a0,0x5
ffffffffc0200784:	f0050513          	addi	a0,a0,-256 # ffffffffc0205680 <commands+0x690>
ffffffffc0200788:	949ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s4       0x%08x\n", gpr->s4);
ffffffffc020078c:	704c                	ld	a1,160(s0)
ffffffffc020078e:	00005517          	auipc	a0,0x5
ffffffffc0200792:	f0a50513          	addi	a0,a0,-246 # ffffffffc0205698 <commands+0x6a8>
ffffffffc0200796:	93bff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s5       0x%08x\n", gpr->s5);
ffffffffc020079a:	744c                	ld	a1,168(s0)
ffffffffc020079c:	00005517          	auipc	a0,0x5
ffffffffc02007a0:	f1450513          	addi	a0,a0,-236 # ffffffffc02056b0 <commands+0x6c0>
ffffffffc02007a4:	92dff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s6       0x%08x\n", gpr->s6);
ffffffffc02007a8:	784c                	ld	a1,176(s0)
ffffffffc02007aa:	00005517          	auipc	a0,0x5
ffffffffc02007ae:	f1e50513          	addi	a0,a0,-226 # ffffffffc02056c8 <commands+0x6d8>
ffffffffc02007b2:	91fff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s7       0x%08x\n", gpr->s7);
ffffffffc02007b6:	7c4c                	ld	a1,184(s0)
ffffffffc02007b8:	00005517          	auipc	a0,0x5
ffffffffc02007bc:	f2850513          	addi	a0,a0,-216 # ffffffffc02056e0 <commands+0x6f0>
ffffffffc02007c0:	911ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s8       0x%08x\n", gpr->s8);
ffffffffc02007c4:	606c                	ld	a1,192(s0)
ffffffffc02007c6:	00005517          	auipc	a0,0x5
ffffffffc02007ca:	f3250513          	addi	a0,a0,-206 # ffffffffc02056f8 <commands+0x708>
ffffffffc02007ce:	903ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s9       0x%08x\n", gpr->s9);
ffffffffc02007d2:	646c                	ld	a1,200(s0)
ffffffffc02007d4:	00005517          	auipc	a0,0x5
ffffffffc02007d8:	f3c50513          	addi	a0,a0,-196 # ffffffffc0205710 <commands+0x720>
ffffffffc02007dc:	8f5ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s10      0x%08x\n", gpr->s10);
ffffffffc02007e0:	686c                	ld	a1,208(s0)
ffffffffc02007e2:	00005517          	auipc	a0,0x5
ffffffffc02007e6:	f4650513          	addi	a0,a0,-186 # ffffffffc0205728 <commands+0x738>
ffffffffc02007ea:	8e7ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  s11      0x%08x\n", gpr->s11);
ffffffffc02007ee:	6c6c                	ld	a1,216(s0)
ffffffffc02007f0:	00005517          	auipc	a0,0x5
ffffffffc02007f4:	f5050513          	addi	a0,a0,-176 # ffffffffc0205740 <commands+0x750>
ffffffffc02007f8:	8d9ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  t3       0x%08x\n", gpr->t3);
ffffffffc02007fc:	706c                	ld	a1,224(s0)
ffffffffc02007fe:	00005517          	auipc	a0,0x5
ffffffffc0200802:	f5a50513          	addi	a0,a0,-166 # ffffffffc0205758 <commands+0x768>
ffffffffc0200806:	8cbff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  t4       0x%08x\n", gpr->t4);
ffffffffc020080a:	746c                	ld	a1,232(s0)
ffffffffc020080c:	00005517          	auipc	a0,0x5
ffffffffc0200810:	f6450513          	addi	a0,a0,-156 # ffffffffc0205770 <commands+0x780>
ffffffffc0200814:	8bdff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  t5       0x%08x\n", gpr->t5);
ffffffffc0200818:	786c                	ld	a1,240(s0)
ffffffffc020081a:	00005517          	auipc	a0,0x5
ffffffffc020081e:	f6e50513          	addi	a0,a0,-146 # ffffffffc0205788 <commands+0x798>
ffffffffc0200822:	8afff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc0200826:	7c6c                	ld	a1,248(s0)
}
ffffffffc0200828:	6402                	ld	s0,0(sp)
ffffffffc020082a:	60a2                	ld	ra,8(sp)
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc020082c:	00005517          	auipc	a0,0x5
ffffffffc0200830:	f7450513          	addi	a0,a0,-140 # ffffffffc02057a0 <commands+0x7b0>
}
ffffffffc0200834:	0141                	addi	sp,sp,16
    cprintf("  t6       0x%08x\n", gpr->t6);
ffffffffc0200836:	89bff06f          	j	ffffffffc02000d0 <cprintf>

ffffffffc020083a <print_trapframe>:
void print_trapframe(struct trapframe *tf) {
ffffffffc020083a:	1141                	addi	sp,sp,-16
ffffffffc020083c:	e022                	sd	s0,0(sp)
    cprintf("trapframe at %p\n", tf);
ffffffffc020083e:	85aa                	mv	a1,a0
void print_trapframe(struct trapframe *tf) {
ffffffffc0200840:	842a                	mv	s0,a0
    cprintf("trapframe at %p\n", tf);
ffffffffc0200842:	00005517          	auipc	a0,0x5
ffffffffc0200846:	f7650513          	addi	a0,a0,-138 # ffffffffc02057b8 <commands+0x7c8>
void print_trapframe(struct trapframe *tf) {
ffffffffc020084a:	e406                	sd	ra,8(sp)
    cprintf("trapframe at %p\n", tf);
ffffffffc020084c:	885ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    print_regs(&tf->gpr);
ffffffffc0200850:	8522                	mv	a0,s0
ffffffffc0200852:	e1bff0ef          	jal	ra,ffffffffc020066c <print_regs>
    cprintf("  status   0x%08x\n", tf->status);
ffffffffc0200856:	10043583          	ld	a1,256(s0)
ffffffffc020085a:	00005517          	auipc	a0,0x5
ffffffffc020085e:	f7650513          	addi	a0,a0,-138 # ffffffffc02057d0 <commands+0x7e0>
ffffffffc0200862:	86fff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  epc      0x%08x\n", tf->epc);
ffffffffc0200866:	10843583          	ld	a1,264(s0)
ffffffffc020086a:	00005517          	auipc	a0,0x5
ffffffffc020086e:	f7e50513          	addi	a0,a0,-130 # ffffffffc02057e8 <commands+0x7f8>
ffffffffc0200872:	85fff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  badvaddr 0x%08x\n", tf->badvaddr);
ffffffffc0200876:	11043583          	ld	a1,272(s0)
ffffffffc020087a:	00005517          	auipc	a0,0x5
ffffffffc020087e:	f8650513          	addi	a0,a0,-122 # ffffffffc0205800 <commands+0x810>
ffffffffc0200882:	84fff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc0200886:	11843583          	ld	a1,280(s0)
}
ffffffffc020088a:	6402                	ld	s0,0(sp)
ffffffffc020088c:	60a2                	ld	ra,8(sp)
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc020088e:	00005517          	auipc	a0,0x5
ffffffffc0200892:	f8a50513          	addi	a0,a0,-118 # ffffffffc0205818 <commands+0x828>
}
ffffffffc0200896:	0141                	addi	sp,sp,16
    cprintf("  cause    0x%08x\n", tf->cause);
ffffffffc0200898:	839ff06f          	j	ffffffffc02000d0 <cprintf>

ffffffffc020089c <interrupt_handler>:

static volatile int in_swap_tick_event = 0;
extern struct mm_struct *check_mm_struct;

void interrupt_handler(struct trapframe *tf) {
    intptr_t cause = (tf->cause << 1) >> 1;
ffffffffc020089c:	11853783          	ld	a5,280(a0)
ffffffffc02008a0:	577d                	li	a4,-1
ffffffffc02008a2:	8305                	srli	a4,a4,0x1
ffffffffc02008a4:	8ff9                	and	a5,a5,a4
    switch (cause) {
ffffffffc02008a6:	472d                	li	a4,11
ffffffffc02008a8:	06f76f63          	bltu	a4,a5,ffffffffc0200926 <interrupt_handler+0x8a>
ffffffffc02008ac:	00005717          	auipc	a4,0x5
ffffffffc02008b0:	8e070713          	addi	a4,a4,-1824 # ffffffffc020518c <commands+0x19c>
ffffffffc02008b4:	078a                	slli	a5,a5,0x2
ffffffffc02008b6:	97ba                	add	a5,a5,a4
ffffffffc02008b8:	439c                	lw	a5,0(a5)
ffffffffc02008ba:	97ba                	add	a5,a5,a4
ffffffffc02008bc:	8782                	jr	a5
            break;
        case IRQ_H_SOFT:
            cprintf("Hypervisor software interrupt\n");
            break;
        case IRQ_M_SOFT:
            cprintf("Machine software interrupt\n");
ffffffffc02008be:	00005517          	auipc	a0,0x5
ffffffffc02008c2:	b5a50513          	addi	a0,a0,-1190 # ffffffffc0205418 <commands+0x428>
ffffffffc02008c6:	80bff06f          	j	ffffffffc02000d0 <cprintf>
            cprintf("Hypervisor software interrupt\n");
ffffffffc02008ca:	00005517          	auipc	a0,0x5
ffffffffc02008ce:	b2e50513          	addi	a0,a0,-1234 # ffffffffc02053f8 <commands+0x408>
ffffffffc02008d2:	ffeff06f          	j	ffffffffc02000d0 <cprintf>
            cprintf("User software interrupt\n");
ffffffffc02008d6:	00005517          	auipc	a0,0x5
ffffffffc02008da:	ae250513          	addi	a0,a0,-1310 # ffffffffc02053b8 <commands+0x3c8>
ffffffffc02008de:	ff2ff06f          	j	ffffffffc02000d0 <cprintf>
            cprintf("Supervisor software interrupt\n");
ffffffffc02008e2:	00005517          	auipc	a0,0x5
ffffffffc02008e6:	af650513          	addi	a0,a0,-1290 # ffffffffc02053d8 <commands+0x3e8>
ffffffffc02008ea:	fe6ff06f          	j	ffffffffc02000d0 <cprintf>
            break;
        case IRQ_U_EXT:
            cprintf("User software interrupt\n");
            break;
        case IRQ_S_EXT:
            cprintf("Supervisor external interrupt\n");
ffffffffc02008ee:	00005517          	auipc	a0,0x5
ffffffffc02008f2:	b5a50513          	addi	a0,a0,-1190 # ffffffffc0205448 <commands+0x458>
ffffffffc02008f6:	fdaff06f          	j	ffffffffc02000d0 <cprintf>
void interrupt_handler(struct trapframe *tf) {
ffffffffc02008fa:	1141                	addi	sp,sp,-16
ffffffffc02008fc:	e406                	sd	ra,8(sp)
            clock_set_next_event();
ffffffffc02008fe:	c45ff0ef          	jal	ra,ffffffffc0200542 <clock_set_next_event>
            if (++ticks % TICK_NUM == 0) {
ffffffffc0200902:	00015797          	auipc	a5,0x15
ffffffffc0200906:	bce78793          	addi	a5,a5,-1074 # ffffffffc02154d0 <ticks>
ffffffffc020090a:	639c                	ld	a5,0(a5)
ffffffffc020090c:	06400713          	li	a4,100
ffffffffc0200910:	0785                	addi	a5,a5,1
ffffffffc0200912:	02e7f733          	remu	a4,a5,a4
ffffffffc0200916:	00015697          	auipc	a3,0x15
ffffffffc020091a:	baf6bd23          	sd	a5,-1094(a3) # ffffffffc02154d0 <ticks>
ffffffffc020091e:	c711                	beqz	a4,ffffffffc020092a <interrupt_handler+0x8e>
            break;
        default:
            print_trapframe(tf);
            break;
    }
}
ffffffffc0200920:	60a2                	ld	ra,8(sp)
ffffffffc0200922:	0141                	addi	sp,sp,16
ffffffffc0200924:	8082                	ret
            print_trapframe(tf);
ffffffffc0200926:	f15ff06f          	j	ffffffffc020083a <print_trapframe>
}
ffffffffc020092a:	60a2                	ld	ra,8(sp)
    cprintf("%d ticks\n", TICK_NUM);
ffffffffc020092c:	06400593          	li	a1,100
ffffffffc0200930:	00005517          	auipc	a0,0x5
ffffffffc0200934:	b0850513          	addi	a0,a0,-1272 # ffffffffc0205438 <commands+0x448>
}
ffffffffc0200938:	0141                	addi	sp,sp,16
    cprintf("%d ticks\n", TICK_NUM);
ffffffffc020093a:	f96ff06f          	j	ffffffffc02000d0 <cprintf>

ffffffffc020093e <exception_handler>:

void exception_handler(struct trapframe *tf) {
    int ret;
    switch (tf->cause) {
ffffffffc020093e:	11853783          	ld	a5,280(a0)
ffffffffc0200942:	473d                	li	a4,15
ffffffffc0200944:	16f76563          	bltu	a4,a5,ffffffffc0200aae <exception_handler+0x170>
ffffffffc0200948:	00005717          	auipc	a4,0x5
ffffffffc020094c:	87470713          	addi	a4,a4,-1932 # ffffffffc02051bc <commands+0x1cc>
ffffffffc0200950:	078a                	slli	a5,a5,0x2
ffffffffc0200952:	97ba                	add	a5,a5,a4
ffffffffc0200954:	439c                	lw	a5,0(a5)
void exception_handler(struct trapframe *tf) {
ffffffffc0200956:	1101                	addi	sp,sp,-32
ffffffffc0200958:	e822                	sd	s0,16(sp)
ffffffffc020095a:	ec06                	sd	ra,24(sp)
ffffffffc020095c:	e426                	sd	s1,8(sp)
    switch (tf->cause) {
ffffffffc020095e:	97ba                	add	a5,a5,a4
ffffffffc0200960:	842a                	mv	s0,a0
ffffffffc0200962:	8782                	jr	a5
                print_trapframe(tf);
                panic("handle pgfault failed. %e\n", ret);
            }
            break;
        case CAUSE_STORE_PAGE_FAULT:
            cprintf("Store/AMO page fault\n");
ffffffffc0200964:	00005517          	auipc	a0,0x5
ffffffffc0200968:	a3c50513          	addi	a0,a0,-1476 # ffffffffc02053a0 <commands+0x3b0>
ffffffffc020096c:	f64ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
            if ((ret = pgfault_handler(tf)) != 0) {
ffffffffc0200970:	8522                	mv	a0,s0
ffffffffc0200972:	c6fff0ef          	jal	ra,ffffffffc02005e0 <pgfault_handler>
ffffffffc0200976:	84aa                	mv	s1,a0
ffffffffc0200978:	12051d63          	bnez	a0,ffffffffc0200ab2 <exception_handler+0x174>
            break;
        default:
            print_trapframe(tf);
            break;
    }
}
ffffffffc020097c:	60e2                	ld	ra,24(sp)
ffffffffc020097e:	6442                	ld	s0,16(sp)
ffffffffc0200980:	64a2                	ld	s1,8(sp)
ffffffffc0200982:	6105                	addi	sp,sp,32
ffffffffc0200984:	8082                	ret
            cprintf("Instruction address misaligned\n");
ffffffffc0200986:	00005517          	auipc	a0,0x5
ffffffffc020098a:	87a50513          	addi	a0,a0,-1926 # ffffffffc0205200 <commands+0x210>
}
ffffffffc020098e:	6442                	ld	s0,16(sp)
ffffffffc0200990:	60e2                	ld	ra,24(sp)
ffffffffc0200992:	64a2                	ld	s1,8(sp)
ffffffffc0200994:	6105                	addi	sp,sp,32
            cprintf("Instruction access fault\n");
ffffffffc0200996:	f3aff06f          	j	ffffffffc02000d0 <cprintf>
ffffffffc020099a:	00005517          	auipc	a0,0x5
ffffffffc020099e:	88650513          	addi	a0,a0,-1914 # ffffffffc0205220 <commands+0x230>
ffffffffc02009a2:	b7f5                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Illegal instruction\n");
ffffffffc02009a4:	00005517          	auipc	a0,0x5
ffffffffc02009a8:	89c50513          	addi	a0,a0,-1892 # ffffffffc0205240 <commands+0x250>
ffffffffc02009ac:	b7cd                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Breakpoint\n");
ffffffffc02009ae:	00005517          	auipc	a0,0x5
ffffffffc02009b2:	8aa50513          	addi	a0,a0,-1878 # ffffffffc0205258 <commands+0x268>
ffffffffc02009b6:	bfe1                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Load address misaligned\n");
ffffffffc02009b8:	00005517          	auipc	a0,0x5
ffffffffc02009bc:	8b050513          	addi	a0,a0,-1872 # ffffffffc0205268 <commands+0x278>
ffffffffc02009c0:	b7f9                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Load access fault\n");
ffffffffc02009c2:	00005517          	auipc	a0,0x5
ffffffffc02009c6:	8c650513          	addi	a0,a0,-1850 # ffffffffc0205288 <commands+0x298>
ffffffffc02009ca:	f06ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
            if ((ret = pgfault_handler(tf)) != 0) {
ffffffffc02009ce:	8522                	mv	a0,s0
ffffffffc02009d0:	c11ff0ef          	jal	ra,ffffffffc02005e0 <pgfault_handler>
ffffffffc02009d4:	84aa                	mv	s1,a0
ffffffffc02009d6:	d15d                	beqz	a0,ffffffffc020097c <exception_handler+0x3e>
                print_trapframe(tf);
ffffffffc02009d8:	8522                	mv	a0,s0
ffffffffc02009da:	e61ff0ef          	jal	ra,ffffffffc020083a <print_trapframe>
                panic("handle pgfault failed. %e\n", ret);
ffffffffc02009de:	86a6                	mv	a3,s1
ffffffffc02009e0:	00005617          	auipc	a2,0x5
ffffffffc02009e4:	8c060613          	addi	a2,a2,-1856 # ffffffffc02052a0 <commands+0x2b0>
ffffffffc02009e8:	0b300593          	li	a1,179
ffffffffc02009ec:	00005517          	auipc	a0,0x5
ffffffffc02009f0:	ab450513          	addi	a0,a0,-1356 # ffffffffc02054a0 <commands+0x4b0>
ffffffffc02009f4:	fe2ff0ef          	jal	ra,ffffffffc02001d6 <__panic>
            cprintf("AMO address misaligned\n");
ffffffffc02009f8:	00005517          	auipc	a0,0x5
ffffffffc02009fc:	8c850513          	addi	a0,a0,-1848 # ffffffffc02052c0 <commands+0x2d0>
ffffffffc0200a00:	b779                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Store/AMO access fault\n");
ffffffffc0200a02:	00005517          	auipc	a0,0x5
ffffffffc0200a06:	8d650513          	addi	a0,a0,-1834 # ffffffffc02052d8 <commands+0x2e8>
ffffffffc0200a0a:	ec6ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
            if ((ret = pgfault_handler(tf)) != 0) {
ffffffffc0200a0e:	8522                	mv	a0,s0
ffffffffc0200a10:	bd1ff0ef          	jal	ra,ffffffffc02005e0 <pgfault_handler>
ffffffffc0200a14:	84aa                	mv	s1,a0
ffffffffc0200a16:	d13d                	beqz	a0,ffffffffc020097c <exception_handler+0x3e>
                print_trapframe(tf);
ffffffffc0200a18:	8522                	mv	a0,s0
ffffffffc0200a1a:	e21ff0ef          	jal	ra,ffffffffc020083a <print_trapframe>
                panic("handle pgfault failed. %e\n", ret);
ffffffffc0200a1e:	86a6                	mv	a3,s1
ffffffffc0200a20:	00005617          	auipc	a2,0x5
ffffffffc0200a24:	88060613          	addi	a2,a2,-1920 # ffffffffc02052a0 <commands+0x2b0>
ffffffffc0200a28:	0bd00593          	li	a1,189
ffffffffc0200a2c:	00005517          	auipc	a0,0x5
ffffffffc0200a30:	a7450513          	addi	a0,a0,-1420 # ffffffffc02054a0 <commands+0x4b0>
ffffffffc0200a34:	fa2ff0ef          	jal	ra,ffffffffc02001d6 <__panic>
            cprintf("Environment call from U-mode\n");
ffffffffc0200a38:	00005517          	auipc	a0,0x5
ffffffffc0200a3c:	8b850513          	addi	a0,a0,-1864 # ffffffffc02052f0 <commands+0x300>
ffffffffc0200a40:	b7b9                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Environment call from S-mode\n");
ffffffffc0200a42:	00005517          	auipc	a0,0x5
ffffffffc0200a46:	8ce50513          	addi	a0,a0,-1842 # ffffffffc0205310 <commands+0x320>
ffffffffc0200a4a:	b791                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Environment call from H-mode\n");
ffffffffc0200a4c:	00005517          	auipc	a0,0x5
ffffffffc0200a50:	8e450513          	addi	a0,a0,-1820 # ffffffffc0205330 <commands+0x340>
ffffffffc0200a54:	bf2d                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Environment call from M-mode\n");
ffffffffc0200a56:	00005517          	auipc	a0,0x5
ffffffffc0200a5a:	8fa50513          	addi	a0,a0,-1798 # ffffffffc0205350 <commands+0x360>
ffffffffc0200a5e:	bf05                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Instruction page fault\n");
ffffffffc0200a60:	00005517          	auipc	a0,0x5
ffffffffc0200a64:	91050513          	addi	a0,a0,-1776 # ffffffffc0205370 <commands+0x380>
ffffffffc0200a68:	b71d                	j	ffffffffc020098e <exception_handler+0x50>
            cprintf("Load page fault\n");
ffffffffc0200a6a:	00005517          	auipc	a0,0x5
ffffffffc0200a6e:	91e50513          	addi	a0,a0,-1762 # ffffffffc0205388 <commands+0x398>
ffffffffc0200a72:	e5eff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
            if ((ret = pgfault_handler(tf)) != 0) {
ffffffffc0200a76:	8522                	mv	a0,s0
ffffffffc0200a78:	b69ff0ef          	jal	ra,ffffffffc02005e0 <pgfault_handler>
ffffffffc0200a7c:	84aa                	mv	s1,a0
ffffffffc0200a7e:	ee050fe3          	beqz	a0,ffffffffc020097c <exception_handler+0x3e>
                print_trapframe(tf);
ffffffffc0200a82:	8522                	mv	a0,s0
ffffffffc0200a84:	db7ff0ef          	jal	ra,ffffffffc020083a <print_trapframe>
                panic("handle pgfault failed. %e\n", ret);
ffffffffc0200a88:	86a6                	mv	a3,s1
ffffffffc0200a8a:	00005617          	auipc	a2,0x5
ffffffffc0200a8e:	81660613          	addi	a2,a2,-2026 # ffffffffc02052a0 <commands+0x2b0>
ffffffffc0200a92:	0d300593          	li	a1,211
ffffffffc0200a96:	00005517          	auipc	a0,0x5
ffffffffc0200a9a:	a0a50513          	addi	a0,a0,-1526 # ffffffffc02054a0 <commands+0x4b0>
ffffffffc0200a9e:	f38ff0ef          	jal	ra,ffffffffc02001d6 <__panic>
}
ffffffffc0200aa2:	6442                	ld	s0,16(sp)
ffffffffc0200aa4:	60e2                	ld	ra,24(sp)
ffffffffc0200aa6:	64a2                	ld	s1,8(sp)
ffffffffc0200aa8:	6105                	addi	sp,sp,32
            print_trapframe(tf);
ffffffffc0200aaa:	d91ff06f          	j	ffffffffc020083a <print_trapframe>
ffffffffc0200aae:	d8dff06f          	j	ffffffffc020083a <print_trapframe>
                print_trapframe(tf);
ffffffffc0200ab2:	8522                	mv	a0,s0
ffffffffc0200ab4:	d87ff0ef          	jal	ra,ffffffffc020083a <print_trapframe>
                panic("handle pgfault failed. %e\n", ret);
ffffffffc0200ab8:	86a6                	mv	a3,s1
ffffffffc0200aba:	00004617          	auipc	a2,0x4
ffffffffc0200abe:	7e660613          	addi	a2,a2,2022 # ffffffffc02052a0 <commands+0x2b0>
ffffffffc0200ac2:	0da00593          	li	a1,218
ffffffffc0200ac6:	00005517          	auipc	a0,0x5
ffffffffc0200aca:	9da50513          	addi	a0,a0,-1574 # ffffffffc02054a0 <commands+0x4b0>
ffffffffc0200ace:	f08ff0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0200ad2 <trap>:
 * the code in kern/trap/trapentry.S restores the old CPU state saved in the
 * trapframe and then uses the iret instruction to return from the exception.
 * */
void trap(struct trapframe *tf) {
    // dispatch based on what type of trap occurred
    if ((intptr_t)tf->cause < 0) {
ffffffffc0200ad2:	11853783          	ld	a5,280(a0)
ffffffffc0200ad6:	0007c463          	bltz	a5,ffffffffc0200ade <trap+0xc>
        // interrupts
        interrupt_handler(tf);
    } else {
        // exceptions
        exception_handler(tf);
ffffffffc0200ada:	e65ff06f          	j	ffffffffc020093e <exception_handler>
        interrupt_handler(tf);
ffffffffc0200ade:	dbfff06f          	j	ffffffffc020089c <interrupt_handler>
	...

ffffffffc0200ae4 <__alltraps>:
    LOAD  x2,2*REGBYTES(sp)
    .endm

    .globl __alltraps
__alltraps:
    SAVE_ALL
ffffffffc0200ae4:	14011073          	csrw	sscratch,sp
ffffffffc0200ae8:	712d                	addi	sp,sp,-288
ffffffffc0200aea:	e406                	sd	ra,8(sp)
ffffffffc0200aec:	ec0e                	sd	gp,24(sp)
ffffffffc0200aee:	f012                	sd	tp,32(sp)
ffffffffc0200af0:	f416                	sd	t0,40(sp)
ffffffffc0200af2:	f81a                	sd	t1,48(sp)
ffffffffc0200af4:	fc1e                	sd	t2,56(sp)
ffffffffc0200af6:	e0a2                	sd	s0,64(sp)
ffffffffc0200af8:	e4a6                	sd	s1,72(sp)
ffffffffc0200afa:	e8aa                	sd	a0,80(sp)
ffffffffc0200afc:	ecae                	sd	a1,88(sp)
ffffffffc0200afe:	f0b2                	sd	a2,96(sp)
ffffffffc0200b00:	f4b6                	sd	a3,104(sp)
ffffffffc0200b02:	f8ba                	sd	a4,112(sp)
ffffffffc0200b04:	fcbe                	sd	a5,120(sp)
ffffffffc0200b06:	e142                	sd	a6,128(sp)
ffffffffc0200b08:	e546                	sd	a7,136(sp)
ffffffffc0200b0a:	e94a                	sd	s2,144(sp)
ffffffffc0200b0c:	ed4e                	sd	s3,152(sp)
ffffffffc0200b0e:	f152                	sd	s4,160(sp)
ffffffffc0200b10:	f556                	sd	s5,168(sp)
ffffffffc0200b12:	f95a                	sd	s6,176(sp)
ffffffffc0200b14:	fd5e                	sd	s7,184(sp)
ffffffffc0200b16:	e1e2                	sd	s8,192(sp)
ffffffffc0200b18:	e5e6                	sd	s9,200(sp)
ffffffffc0200b1a:	e9ea                	sd	s10,208(sp)
ffffffffc0200b1c:	edee                	sd	s11,216(sp)
ffffffffc0200b1e:	f1f2                	sd	t3,224(sp)
ffffffffc0200b20:	f5f6                	sd	t4,232(sp)
ffffffffc0200b22:	f9fa                	sd	t5,240(sp)
ffffffffc0200b24:	fdfe                	sd	t6,248(sp)
ffffffffc0200b26:	14002473          	csrr	s0,sscratch
ffffffffc0200b2a:	100024f3          	csrr	s1,sstatus
ffffffffc0200b2e:	14102973          	csrr	s2,sepc
ffffffffc0200b32:	143029f3          	csrr	s3,stval
ffffffffc0200b36:	14202a73          	csrr	s4,scause
ffffffffc0200b3a:	e822                	sd	s0,16(sp)
ffffffffc0200b3c:	e226                	sd	s1,256(sp)
ffffffffc0200b3e:	e64a                	sd	s2,264(sp)
ffffffffc0200b40:	ea4e                	sd	s3,272(sp)
ffffffffc0200b42:	ee52                	sd	s4,280(sp)

    move  a0, sp
ffffffffc0200b44:	850a                	mv	a0,sp
    jal trap
ffffffffc0200b46:	f8dff0ef          	jal	ra,ffffffffc0200ad2 <trap>

ffffffffc0200b4a <__trapret>:
    # sp should be the same as before "jal trap"

    .globl __trapret
__trapret:
    RESTORE_ALL
ffffffffc0200b4a:	6492                	ld	s1,256(sp)
ffffffffc0200b4c:	6932                	ld	s2,264(sp)
ffffffffc0200b4e:	10049073          	csrw	sstatus,s1
ffffffffc0200b52:	14191073          	csrw	sepc,s2
ffffffffc0200b56:	60a2                	ld	ra,8(sp)
ffffffffc0200b58:	61e2                	ld	gp,24(sp)
ffffffffc0200b5a:	7202                	ld	tp,32(sp)
ffffffffc0200b5c:	72a2                	ld	t0,40(sp)
ffffffffc0200b5e:	7342                	ld	t1,48(sp)
ffffffffc0200b60:	73e2                	ld	t2,56(sp)
ffffffffc0200b62:	6406                	ld	s0,64(sp)
ffffffffc0200b64:	64a6                	ld	s1,72(sp)
ffffffffc0200b66:	6546                	ld	a0,80(sp)
ffffffffc0200b68:	65e6                	ld	a1,88(sp)
ffffffffc0200b6a:	7606                	ld	a2,96(sp)
ffffffffc0200b6c:	76a6                	ld	a3,104(sp)
ffffffffc0200b6e:	7746                	ld	a4,112(sp)
ffffffffc0200b70:	77e6                	ld	a5,120(sp)
ffffffffc0200b72:	680a                	ld	a6,128(sp)
ffffffffc0200b74:	68aa                	ld	a7,136(sp)
ffffffffc0200b76:	694a                	ld	s2,144(sp)
ffffffffc0200b78:	69ea                	ld	s3,152(sp)
ffffffffc0200b7a:	7a0a                	ld	s4,160(sp)
ffffffffc0200b7c:	7aaa                	ld	s5,168(sp)
ffffffffc0200b7e:	7b4a                	ld	s6,176(sp)
ffffffffc0200b80:	7bea                	ld	s7,184(sp)
ffffffffc0200b82:	6c0e                	ld	s8,192(sp)
ffffffffc0200b84:	6cae                	ld	s9,200(sp)
ffffffffc0200b86:	6d4e                	ld	s10,208(sp)
ffffffffc0200b88:	6dee                	ld	s11,216(sp)
ffffffffc0200b8a:	7e0e                	ld	t3,224(sp)
ffffffffc0200b8c:	7eae                	ld	t4,232(sp)
ffffffffc0200b8e:	7f4e                	ld	t5,240(sp)
ffffffffc0200b90:	7fee                	ld	t6,248(sp)
ffffffffc0200b92:	6142                	ld	sp,16(sp)
    # go back from supervisor call
    sret
ffffffffc0200b94:	10200073          	sret

ffffffffc0200b98 <forkrets>:
 
    .globl forkrets
forkrets:
    # set stack to this new process's trapframe
    move sp, a0
ffffffffc0200b98:	812a                	mv	sp,a0
    j __trapret
ffffffffc0200b9a:	bf45                	j	ffffffffc0200b4a <__trapret>
	...

ffffffffc0200b9e <pa2page.part.4>:
page2pa(struct Page *page) {
    return page2ppn(page) << PGSHIFT;
}

static inline struct Page *
pa2page(uintptr_t pa) {
ffffffffc0200b9e:	1141                	addi	sp,sp,-16
    if (PPN(pa) >= npage) {
        panic("pa2page called with invalid pa");
ffffffffc0200ba0:	00005617          	auipc	a2,0x5
ffffffffc0200ba4:	cc860613          	addi	a2,a2,-824 # ffffffffc0205868 <commands+0x878>
ffffffffc0200ba8:	06200593          	li	a1,98
ffffffffc0200bac:	00005517          	auipc	a0,0x5
ffffffffc0200bb0:	cdc50513          	addi	a0,a0,-804 # ffffffffc0205888 <commands+0x898>
pa2page(uintptr_t pa) {
ffffffffc0200bb4:	e406                	sd	ra,8(sp)
        panic("pa2page called with invalid pa");
ffffffffc0200bb6:	e20ff0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0200bba <alloc_pages>:
    pmm_manager->init_memmap(base, n);
}

// alloc_pages - call pmm->alloc_pages to allocate a continuous n*PAGESIZE
// memory
struct Page *alloc_pages(size_t n) {
ffffffffc0200bba:	715d                	addi	sp,sp,-80
ffffffffc0200bbc:	e0a2                	sd	s0,64(sp)
ffffffffc0200bbe:	fc26                	sd	s1,56(sp)
ffffffffc0200bc0:	f84a                	sd	s2,48(sp)
ffffffffc0200bc2:	f44e                	sd	s3,40(sp)
ffffffffc0200bc4:	f052                	sd	s4,32(sp)
ffffffffc0200bc6:	ec56                	sd	s5,24(sp)
ffffffffc0200bc8:	e486                	sd	ra,72(sp)
ffffffffc0200bca:	842a                	mv	s0,a0
ffffffffc0200bcc:	00015497          	auipc	s1,0x15
ffffffffc0200bd0:	90c48493          	addi	s1,s1,-1780 # ffffffffc02154d8 <pmm_manager>
        {
            page = pmm_manager->alloc_pages(n);
        }
        local_intr_restore(intr_flag);

        if (page != NULL || n > 1 || swap_init_ok == 0) break;
ffffffffc0200bd4:	4985                	li	s3,1
ffffffffc0200bd6:	00015a17          	auipc	s4,0x15
ffffffffc0200bda:	8caa0a13          	addi	s4,s4,-1846 # ffffffffc02154a0 <swap_init_ok>

        extern struct mm_struct *check_mm_struct;
        // cprintf("page %x, call swap_out in alloc_pages %d\n",page, n);
        swap_out(check_mm_struct, n, 0);
ffffffffc0200bde:	0005091b          	sext.w	s2,a0
ffffffffc0200be2:	00015a97          	auipc	s5,0x15
ffffffffc0200be6:	916a8a93          	addi	s5,s5,-1770 # ffffffffc02154f8 <check_mm_struct>
ffffffffc0200bea:	a00d                	j	ffffffffc0200c0c <alloc_pages+0x52>
            page = pmm_manager->alloc_pages(n);
ffffffffc0200bec:	609c                	ld	a5,0(s1)
ffffffffc0200bee:	6f9c                	ld	a5,24(a5)
ffffffffc0200bf0:	9782                	jalr	a5
        swap_out(check_mm_struct, n, 0);
ffffffffc0200bf2:	4601                	li	a2,0
ffffffffc0200bf4:	85ca                	mv	a1,s2
        if (page != NULL || n > 1 || swap_init_ok == 0) break;
ffffffffc0200bf6:	ed0d                	bnez	a0,ffffffffc0200c30 <alloc_pages+0x76>
ffffffffc0200bf8:	0289ec63          	bltu	s3,s0,ffffffffc0200c30 <alloc_pages+0x76>
ffffffffc0200bfc:	000a2783          	lw	a5,0(s4)
ffffffffc0200c00:	2781                	sext.w	a5,a5
ffffffffc0200c02:	c79d                	beqz	a5,ffffffffc0200c30 <alloc_pages+0x76>
        swap_out(check_mm_struct, n, 0);
ffffffffc0200c04:	000ab503          	ld	a0,0(s5)
ffffffffc0200c08:	703010ef          	jal	ra,ffffffffc0202b0a <swap_out>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0200c0c:	100027f3          	csrr	a5,sstatus
ffffffffc0200c10:	8b89                	andi	a5,a5,2
            page = pmm_manager->alloc_pages(n);
ffffffffc0200c12:	8522                	mv	a0,s0
ffffffffc0200c14:	dfe1                	beqz	a5,ffffffffc0200bec <alloc_pages+0x32>
        intr_disable();
ffffffffc0200c16:	9c5ff0ef          	jal	ra,ffffffffc02005da <intr_disable>
ffffffffc0200c1a:	609c                	ld	a5,0(s1)
ffffffffc0200c1c:	8522                	mv	a0,s0
ffffffffc0200c1e:	6f9c                	ld	a5,24(a5)
ffffffffc0200c20:	9782                	jalr	a5
ffffffffc0200c22:	e42a                	sd	a0,8(sp)
        intr_enable();
ffffffffc0200c24:	9b1ff0ef          	jal	ra,ffffffffc02005d4 <intr_enable>
ffffffffc0200c28:	6522                	ld	a0,8(sp)
        swap_out(check_mm_struct, n, 0);
ffffffffc0200c2a:	4601                	li	a2,0
ffffffffc0200c2c:	85ca                	mv	a1,s2
        if (page != NULL || n > 1 || swap_init_ok == 0) break;
ffffffffc0200c2e:	d569                	beqz	a0,ffffffffc0200bf8 <alloc_pages+0x3e>
    }
    // cprintf("n %d,get page %x, No %d in alloc_pages\n",n,page,(page-pages));
    return page;
}
ffffffffc0200c30:	60a6                	ld	ra,72(sp)
ffffffffc0200c32:	6406                	ld	s0,64(sp)
ffffffffc0200c34:	74e2                	ld	s1,56(sp)
ffffffffc0200c36:	7942                	ld	s2,48(sp)
ffffffffc0200c38:	79a2                	ld	s3,40(sp)
ffffffffc0200c3a:	7a02                	ld	s4,32(sp)
ffffffffc0200c3c:	6ae2                	ld	s5,24(sp)
ffffffffc0200c3e:	6161                	addi	sp,sp,80
ffffffffc0200c40:	8082                	ret

ffffffffc0200c42 <free_pages>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0200c42:	100027f3          	csrr	a5,sstatus
ffffffffc0200c46:	8b89                	andi	a5,a5,2
ffffffffc0200c48:	eb89                	bnez	a5,ffffffffc0200c5a <free_pages+0x18>
// free_pages - call pmm->free_pages to free a continuous n*PAGESIZE memory
void free_pages(struct Page *base, size_t n) {
    bool intr_flag;
    local_intr_save(intr_flag);
    {
        pmm_manager->free_pages(base, n);
ffffffffc0200c4a:	00015797          	auipc	a5,0x15
ffffffffc0200c4e:	88e78793          	addi	a5,a5,-1906 # ffffffffc02154d8 <pmm_manager>
ffffffffc0200c52:	639c                	ld	a5,0(a5)
ffffffffc0200c54:	0207b303          	ld	t1,32(a5)
ffffffffc0200c58:	8302                	jr	t1
void free_pages(struct Page *base, size_t n) {
ffffffffc0200c5a:	1101                	addi	sp,sp,-32
ffffffffc0200c5c:	ec06                	sd	ra,24(sp)
ffffffffc0200c5e:	e822                	sd	s0,16(sp)
ffffffffc0200c60:	e426                	sd	s1,8(sp)
ffffffffc0200c62:	842a                	mv	s0,a0
ffffffffc0200c64:	84ae                	mv	s1,a1
        intr_disable();
ffffffffc0200c66:	975ff0ef          	jal	ra,ffffffffc02005da <intr_disable>
        pmm_manager->free_pages(base, n);
ffffffffc0200c6a:	00015797          	auipc	a5,0x15
ffffffffc0200c6e:	86e78793          	addi	a5,a5,-1938 # ffffffffc02154d8 <pmm_manager>
ffffffffc0200c72:	639c                	ld	a5,0(a5)
ffffffffc0200c74:	85a6                	mv	a1,s1
ffffffffc0200c76:	8522                	mv	a0,s0
ffffffffc0200c78:	739c                	ld	a5,32(a5)
ffffffffc0200c7a:	9782                	jalr	a5
    }
    local_intr_restore(intr_flag);
}
ffffffffc0200c7c:	6442                	ld	s0,16(sp)
ffffffffc0200c7e:	60e2                	ld	ra,24(sp)
ffffffffc0200c80:	64a2                	ld	s1,8(sp)
ffffffffc0200c82:	6105                	addi	sp,sp,32
        intr_enable();
ffffffffc0200c84:	951ff06f          	j	ffffffffc02005d4 <intr_enable>

ffffffffc0200c88 <nr_free_pages>:
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0200c88:	100027f3          	csrr	a5,sstatus
ffffffffc0200c8c:	8b89                	andi	a5,a5,2
ffffffffc0200c8e:	eb89                	bnez	a5,ffffffffc0200ca0 <nr_free_pages+0x18>
size_t nr_free_pages(void) {
    size_t ret;
    bool intr_flag;
    local_intr_save(intr_flag);
    {
        ret = pmm_manager->nr_free_pages();
ffffffffc0200c90:	00015797          	auipc	a5,0x15
ffffffffc0200c94:	84878793          	addi	a5,a5,-1976 # ffffffffc02154d8 <pmm_manager>
ffffffffc0200c98:	639c                	ld	a5,0(a5)
ffffffffc0200c9a:	0287b303          	ld	t1,40(a5)
ffffffffc0200c9e:	8302                	jr	t1
size_t nr_free_pages(void) {
ffffffffc0200ca0:	1141                	addi	sp,sp,-16
ffffffffc0200ca2:	e406                	sd	ra,8(sp)
ffffffffc0200ca4:	e022                	sd	s0,0(sp)
        intr_disable();
ffffffffc0200ca6:	935ff0ef          	jal	ra,ffffffffc02005da <intr_disable>
        ret = pmm_manager->nr_free_pages();
ffffffffc0200caa:	00015797          	auipc	a5,0x15
ffffffffc0200cae:	82e78793          	addi	a5,a5,-2002 # ffffffffc02154d8 <pmm_manager>
ffffffffc0200cb2:	639c                	ld	a5,0(a5)
ffffffffc0200cb4:	779c                	ld	a5,40(a5)
ffffffffc0200cb6:	9782                	jalr	a5
ffffffffc0200cb8:	842a                	mv	s0,a0
        intr_enable();
ffffffffc0200cba:	91bff0ef          	jal	ra,ffffffffc02005d4 <intr_enable>
    }
    local_intr_restore(intr_flag);
    return ret;
}
ffffffffc0200cbe:	8522                	mv	a0,s0
ffffffffc0200cc0:	60a2                	ld	ra,8(sp)
ffffffffc0200cc2:	6402                	ld	s0,0(sp)
ffffffffc0200cc4:	0141                	addi	sp,sp,16
ffffffffc0200cc6:	8082                	ret

ffffffffc0200cc8 <get_pte>:
// parameter:
//  pgdir:  the kernel virtual base address of PDT
//  la:     the linear address need to map
//  create: a logical value to decide if alloc a page for PT
// return vaule: the kernel virtual address of this pte
pte_t *get_pte(pde_t *pgdir, uintptr_t la, bool create) {
ffffffffc0200cc8:	7139                	addi	sp,sp,-64
ffffffffc0200cca:	f426                	sd	s1,40(sp)
    pde_t *pdep1 = &pgdir[PDX1(la)];
ffffffffc0200ccc:	01e5d493          	srli	s1,a1,0x1e
ffffffffc0200cd0:	1ff4f493          	andi	s1,s1,511
ffffffffc0200cd4:	048e                	slli	s1,s1,0x3
ffffffffc0200cd6:	94aa                	add	s1,s1,a0
    if (!(*pdep1 & PTE_V)) {
ffffffffc0200cd8:	6094                	ld	a3,0(s1)
pte_t *get_pte(pde_t *pgdir, uintptr_t la, bool create) {
ffffffffc0200cda:	f04a                	sd	s2,32(sp)
ffffffffc0200cdc:	ec4e                	sd	s3,24(sp)
ffffffffc0200cde:	e852                	sd	s4,16(sp)
ffffffffc0200ce0:	fc06                	sd	ra,56(sp)
ffffffffc0200ce2:	f822                	sd	s0,48(sp)
ffffffffc0200ce4:	e456                	sd	s5,8(sp)
ffffffffc0200ce6:	e05a                	sd	s6,0(sp)
    if (!(*pdep1 & PTE_V)) {
ffffffffc0200ce8:	0016f793          	andi	a5,a3,1
pte_t *get_pte(pde_t *pgdir, uintptr_t la, bool create) {
ffffffffc0200cec:	892e                	mv	s2,a1
ffffffffc0200cee:	8a32                	mv	s4,a2
ffffffffc0200cf0:	00014997          	auipc	s3,0x14
ffffffffc0200cf4:	79898993          	addi	s3,s3,1944 # ffffffffc0215488 <npage>
    if (!(*pdep1 & PTE_V)) {
ffffffffc0200cf8:	e7bd                	bnez	a5,ffffffffc0200d66 <get_pte+0x9e>
        struct Page *page;
        if (!create || (page = alloc_page()) == NULL) {
ffffffffc0200cfa:	12060c63          	beqz	a2,ffffffffc0200e32 <get_pte+0x16a>
ffffffffc0200cfe:	4505                	li	a0,1
ffffffffc0200d00:	ebbff0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0200d04:	842a                	mv	s0,a0
ffffffffc0200d06:	12050663          	beqz	a0,ffffffffc0200e32 <get_pte+0x16a>
    return page - pages + nbase;
ffffffffc0200d0a:	00014b17          	auipc	s6,0x14
ffffffffc0200d0e:	7e6b0b13          	addi	s6,s6,2022 # ffffffffc02154f0 <pages>
ffffffffc0200d12:	000b3503          	ld	a0,0(s6)
    return page->ref;
}

static inline void
set_page_ref(struct Page *page, int val) {
    page->ref = val;
ffffffffc0200d16:	4785                	li	a5,1
            return NULL;
        }
        set_page_ref(page, 1);
        uintptr_t pa = page2pa(page);
        memset(KADDR(pa), 0, PGSIZE);
ffffffffc0200d18:	00014997          	auipc	s3,0x14
ffffffffc0200d1c:	77098993          	addi	s3,s3,1904 # ffffffffc0215488 <npage>
    return page - pages + nbase;
ffffffffc0200d20:	40a40533          	sub	a0,s0,a0
ffffffffc0200d24:	00080ab7          	lui	s5,0x80
ffffffffc0200d28:	8519                	srai	a0,a0,0x6
ffffffffc0200d2a:	0009b703          	ld	a4,0(s3)
    page->ref = val;
ffffffffc0200d2e:	c01c                	sw	a5,0(s0)
ffffffffc0200d30:	57fd                	li	a5,-1
    return page - pages + nbase;
ffffffffc0200d32:	9556                	add	a0,a0,s5
ffffffffc0200d34:	83b1                	srli	a5,a5,0xc
ffffffffc0200d36:	8fe9                	and	a5,a5,a0
    return page2ppn(page) << PGSHIFT;
ffffffffc0200d38:	0532                	slli	a0,a0,0xc
ffffffffc0200d3a:	14e7f363          	bleu	a4,a5,ffffffffc0200e80 <get_pte+0x1b8>
ffffffffc0200d3e:	00014797          	auipc	a5,0x14
ffffffffc0200d42:	7a278793          	addi	a5,a5,1954 # ffffffffc02154e0 <va_pa_offset>
ffffffffc0200d46:	639c                	ld	a5,0(a5)
ffffffffc0200d48:	6605                	lui	a2,0x1
ffffffffc0200d4a:	4581                	li	a1,0
ffffffffc0200d4c:	953e                	add	a0,a0,a5
ffffffffc0200d4e:	4e9030ef          	jal	ra,ffffffffc0204a36 <memset>
    return page - pages + nbase;
ffffffffc0200d52:	000b3683          	ld	a3,0(s6)
ffffffffc0200d56:	40d406b3          	sub	a3,s0,a3
ffffffffc0200d5a:	8699                	srai	a3,a3,0x6
ffffffffc0200d5c:	96d6                	add	a3,a3,s5
  asm volatile("sfence.vma");
}

// construct PTE from a page and permission bits
static inline pte_t pte_create(uintptr_t ppn, int type) {
  return (ppn << PTE_PPN_SHIFT) | PTE_V | type;
ffffffffc0200d5e:	06aa                	slli	a3,a3,0xa
ffffffffc0200d60:	0116e693          	ori	a3,a3,17
        *pdep1 = pte_create(page2ppn(page), PTE_U | PTE_V);
ffffffffc0200d64:	e094                	sd	a3,0(s1)
    }
    pde_t *pdep0 = &((pte_t *)KADDR(PDE_ADDR(*pdep1)))[PDX0(la)];
ffffffffc0200d66:	77fd                	lui	a5,0xfffff
ffffffffc0200d68:	068a                	slli	a3,a3,0x2
ffffffffc0200d6a:	0009b703          	ld	a4,0(s3)
ffffffffc0200d6e:	8efd                	and	a3,a3,a5
ffffffffc0200d70:	00c6d793          	srli	a5,a3,0xc
ffffffffc0200d74:	0ce7f163          	bleu	a4,a5,ffffffffc0200e36 <get_pte+0x16e>
ffffffffc0200d78:	00014a97          	auipc	s5,0x14
ffffffffc0200d7c:	768a8a93          	addi	s5,s5,1896 # ffffffffc02154e0 <va_pa_offset>
ffffffffc0200d80:	000ab403          	ld	s0,0(s5)
ffffffffc0200d84:	01595793          	srli	a5,s2,0x15
ffffffffc0200d88:	1ff7f793          	andi	a5,a5,511
ffffffffc0200d8c:	96a2                	add	a3,a3,s0
ffffffffc0200d8e:	00379413          	slli	s0,a5,0x3
ffffffffc0200d92:	9436                	add	s0,s0,a3
    if (!(*pdep0 & PTE_V)) {
ffffffffc0200d94:	6014                	ld	a3,0(s0)
ffffffffc0200d96:	0016f793          	andi	a5,a3,1
ffffffffc0200d9a:	e3ad                	bnez	a5,ffffffffc0200dfc <get_pte+0x134>
        struct Page *page;
        if (!create || (page = alloc_page()) == NULL) {
ffffffffc0200d9c:	080a0b63          	beqz	s4,ffffffffc0200e32 <get_pte+0x16a>
ffffffffc0200da0:	4505                	li	a0,1
ffffffffc0200da2:	e19ff0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0200da6:	84aa                	mv	s1,a0
ffffffffc0200da8:	c549                	beqz	a0,ffffffffc0200e32 <get_pte+0x16a>
    return page - pages + nbase;
ffffffffc0200daa:	00014b17          	auipc	s6,0x14
ffffffffc0200dae:	746b0b13          	addi	s6,s6,1862 # ffffffffc02154f0 <pages>
ffffffffc0200db2:	000b3503          	ld	a0,0(s6)
    page->ref = val;
ffffffffc0200db6:	4785                	li	a5,1
    return page - pages + nbase;
ffffffffc0200db8:	00080a37          	lui	s4,0x80
ffffffffc0200dbc:	40a48533          	sub	a0,s1,a0
ffffffffc0200dc0:	8519                	srai	a0,a0,0x6
            return NULL;
        }
        set_page_ref(page, 1);
        uintptr_t pa = page2pa(page);
        memset(KADDR(pa), 0, PGSIZE);
ffffffffc0200dc2:	0009b703          	ld	a4,0(s3)
    page->ref = val;
ffffffffc0200dc6:	c09c                	sw	a5,0(s1)
ffffffffc0200dc8:	57fd                	li	a5,-1
    return page - pages + nbase;
ffffffffc0200dca:	9552                	add	a0,a0,s4
ffffffffc0200dcc:	83b1                	srli	a5,a5,0xc
ffffffffc0200dce:	8fe9                	and	a5,a5,a0
    return page2ppn(page) << PGSHIFT;
ffffffffc0200dd0:	0532                	slli	a0,a0,0xc
ffffffffc0200dd2:	08e7fa63          	bleu	a4,a5,ffffffffc0200e66 <get_pte+0x19e>
ffffffffc0200dd6:	000ab783          	ld	a5,0(s5)
ffffffffc0200dda:	6605                	lui	a2,0x1
ffffffffc0200ddc:	4581                	li	a1,0
ffffffffc0200dde:	953e                	add	a0,a0,a5
ffffffffc0200de0:	457030ef          	jal	ra,ffffffffc0204a36 <memset>
    return page - pages + nbase;
ffffffffc0200de4:	000b3683          	ld	a3,0(s6)
ffffffffc0200de8:	40d486b3          	sub	a3,s1,a3
ffffffffc0200dec:	8699                	srai	a3,a3,0x6
ffffffffc0200dee:	96d2                	add	a3,a3,s4
  return (ppn << PTE_PPN_SHIFT) | PTE_V | type;
ffffffffc0200df0:	06aa                	slli	a3,a3,0xa
ffffffffc0200df2:	0116e693          	ori	a3,a3,17
        *pdep0 = pte_create(page2ppn(page), PTE_U | PTE_V);
ffffffffc0200df6:	e014                	sd	a3,0(s0)
ffffffffc0200df8:	0009b703          	ld	a4,0(s3)
    }
    return &((pte_t *)KADDR(PDE_ADDR(*pdep0)))[PTX(la)];
ffffffffc0200dfc:	068a                	slli	a3,a3,0x2
ffffffffc0200dfe:	757d                	lui	a0,0xfffff
ffffffffc0200e00:	8ee9                	and	a3,a3,a0
ffffffffc0200e02:	00c6d793          	srli	a5,a3,0xc
ffffffffc0200e06:	04e7f463          	bleu	a4,a5,ffffffffc0200e4e <get_pte+0x186>
ffffffffc0200e0a:	000ab503          	ld	a0,0(s5)
ffffffffc0200e0e:	00c95793          	srli	a5,s2,0xc
ffffffffc0200e12:	1ff7f793          	andi	a5,a5,511
ffffffffc0200e16:	96aa                	add	a3,a3,a0
ffffffffc0200e18:	00379513          	slli	a0,a5,0x3
ffffffffc0200e1c:	9536                	add	a0,a0,a3
}
ffffffffc0200e1e:	70e2                	ld	ra,56(sp)
ffffffffc0200e20:	7442                	ld	s0,48(sp)
ffffffffc0200e22:	74a2                	ld	s1,40(sp)
ffffffffc0200e24:	7902                	ld	s2,32(sp)
ffffffffc0200e26:	69e2                	ld	s3,24(sp)
ffffffffc0200e28:	6a42                	ld	s4,16(sp)
ffffffffc0200e2a:	6aa2                	ld	s5,8(sp)
ffffffffc0200e2c:	6b02                	ld	s6,0(sp)
ffffffffc0200e2e:	6121                	addi	sp,sp,64
ffffffffc0200e30:	8082                	ret
            return NULL;
ffffffffc0200e32:	4501                	li	a0,0
ffffffffc0200e34:	b7ed                	j	ffffffffc0200e1e <get_pte+0x156>
    pde_t *pdep0 = &((pte_t *)KADDR(PDE_ADDR(*pdep1)))[PDX0(la)];
ffffffffc0200e36:	00005617          	auipc	a2,0x5
ffffffffc0200e3a:	9fa60613          	addi	a2,a2,-1542 # ffffffffc0205830 <commands+0x840>
ffffffffc0200e3e:	0e400593          	li	a1,228
ffffffffc0200e42:	00005517          	auipc	a0,0x5
ffffffffc0200e46:	a1650513          	addi	a0,a0,-1514 # ffffffffc0205858 <commands+0x868>
ffffffffc0200e4a:	b8cff0ef          	jal	ra,ffffffffc02001d6 <__panic>
    return &((pte_t *)KADDR(PDE_ADDR(*pdep0)))[PTX(la)];
ffffffffc0200e4e:	00005617          	auipc	a2,0x5
ffffffffc0200e52:	9e260613          	addi	a2,a2,-1566 # ffffffffc0205830 <commands+0x840>
ffffffffc0200e56:	0ef00593          	li	a1,239
ffffffffc0200e5a:	00005517          	auipc	a0,0x5
ffffffffc0200e5e:	9fe50513          	addi	a0,a0,-1538 # ffffffffc0205858 <commands+0x868>
ffffffffc0200e62:	b74ff0ef          	jal	ra,ffffffffc02001d6 <__panic>
        memset(KADDR(pa), 0, PGSIZE);
ffffffffc0200e66:	86aa                	mv	a3,a0
ffffffffc0200e68:	00005617          	auipc	a2,0x5
ffffffffc0200e6c:	9c860613          	addi	a2,a2,-1592 # ffffffffc0205830 <commands+0x840>
ffffffffc0200e70:	0ec00593          	li	a1,236
ffffffffc0200e74:	00005517          	auipc	a0,0x5
ffffffffc0200e78:	9e450513          	addi	a0,a0,-1564 # ffffffffc0205858 <commands+0x868>
ffffffffc0200e7c:	b5aff0ef          	jal	ra,ffffffffc02001d6 <__panic>
        memset(KADDR(pa), 0, PGSIZE);
ffffffffc0200e80:	86aa                	mv	a3,a0
ffffffffc0200e82:	00005617          	auipc	a2,0x5
ffffffffc0200e86:	9ae60613          	addi	a2,a2,-1618 # ffffffffc0205830 <commands+0x840>
ffffffffc0200e8a:	0e100593          	li	a1,225
ffffffffc0200e8e:	00005517          	auipc	a0,0x5
ffffffffc0200e92:	9ca50513          	addi	a0,a0,-1590 # ffffffffc0205858 <commands+0x868>
ffffffffc0200e96:	b40ff0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0200e9a <get_page>:

// get_page - get related Page struct for linear address la using PDT pgdir
struct Page *get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) {
ffffffffc0200e9a:	1141                	addi	sp,sp,-16
ffffffffc0200e9c:	e022                	sd	s0,0(sp)
ffffffffc0200e9e:	8432                	mv	s0,a2
    pte_t *ptep = get_pte(pgdir, la, 0);
ffffffffc0200ea0:	4601                	li	a2,0
struct Page *get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) {
ffffffffc0200ea2:	e406                	sd	ra,8(sp)
    pte_t *ptep = get_pte(pgdir, la, 0);
ffffffffc0200ea4:	e25ff0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
    if (ptep_store != NULL) {
ffffffffc0200ea8:	c011                	beqz	s0,ffffffffc0200eac <get_page+0x12>
        *ptep_store = ptep;
ffffffffc0200eaa:	e008                	sd	a0,0(s0)
    }
    if (ptep != NULL && *ptep & PTE_V) {
ffffffffc0200eac:	c129                	beqz	a0,ffffffffc0200eee <get_page+0x54>
ffffffffc0200eae:	611c                	ld	a5,0(a0)
        return pte2page(*ptep);
    }
    return NULL;
ffffffffc0200eb0:	4501                	li	a0,0
    if (ptep != NULL && *ptep & PTE_V) {
ffffffffc0200eb2:	0017f713          	andi	a4,a5,1
ffffffffc0200eb6:	e709                	bnez	a4,ffffffffc0200ec0 <get_page+0x26>
}
ffffffffc0200eb8:	60a2                	ld	ra,8(sp)
ffffffffc0200eba:	6402                	ld	s0,0(sp)
ffffffffc0200ebc:	0141                	addi	sp,sp,16
ffffffffc0200ebe:	8082                	ret
    if (PPN(pa) >= npage) {
ffffffffc0200ec0:	00014717          	auipc	a4,0x14
ffffffffc0200ec4:	5c870713          	addi	a4,a4,1480 # ffffffffc0215488 <npage>
ffffffffc0200ec8:	6318                	ld	a4,0(a4)
    return pa2page(PTE_ADDR(pte));
ffffffffc0200eca:	078a                	slli	a5,a5,0x2
ffffffffc0200ecc:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc0200ece:	02e7f563          	bleu	a4,a5,ffffffffc0200ef8 <get_page+0x5e>
    return &pages[PPN(pa) - nbase];
ffffffffc0200ed2:	00014717          	auipc	a4,0x14
ffffffffc0200ed6:	61e70713          	addi	a4,a4,1566 # ffffffffc02154f0 <pages>
ffffffffc0200eda:	6308                	ld	a0,0(a4)
ffffffffc0200edc:	60a2                	ld	ra,8(sp)
ffffffffc0200ede:	6402                	ld	s0,0(sp)
ffffffffc0200ee0:	fff80737          	lui	a4,0xfff80
ffffffffc0200ee4:	97ba                	add	a5,a5,a4
ffffffffc0200ee6:	079a                	slli	a5,a5,0x6
ffffffffc0200ee8:	953e                	add	a0,a0,a5
ffffffffc0200eea:	0141                	addi	sp,sp,16
ffffffffc0200eec:	8082                	ret
ffffffffc0200eee:	60a2                	ld	ra,8(sp)
ffffffffc0200ef0:	6402                	ld	s0,0(sp)
    return NULL;
ffffffffc0200ef2:	4501                	li	a0,0
}
ffffffffc0200ef4:	0141                	addi	sp,sp,16
ffffffffc0200ef6:	8082                	ret
ffffffffc0200ef8:	ca7ff0ef          	jal	ra,ffffffffc0200b9e <pa2page.part.4>

ffffffffc0200efc <page_remove>:
    }
}

// page_remove - free an Page which is related linear address la and has an
// validated pte
void page_remove(pde_t *pgdir, uintptr_t la) {
ffffffffc0200efc:	1101                	addi	sp,sp,-32
    pte_t *ptep = get_pte(pgdir, la, 0);
ffffffffc0200efe:	4601                	li	a2,0
void page_remove(pde_t *pgdir, uintptr_t la) {
ffffffffc0200f00:	e426                	sd	s1,8(sp)
ffffffffc0200f02:	ec06                	sd	ra,24(sp)
ffffffffc0200f04:	e822                	sd	s0,16(sp)
ffffffffc0200f06:	84ae                	mv	s1,a1
    pte_t *ptep = get_pte(pgdir, la, 0);
ffffffffc0200f08:	dc1ff0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
    if (ptep != NULL) {
ffffffffc0200f0c:	c511                	beqz	a0,ffffffffc0200f18 <page_remove+0x1c>
    if (*ptep & PTE_V) {  //(1) check if this page table entry is
ffffffffc0200f0e:	611c                	ld	a5,0(a0)
ffffffffc0200f10:	842a                	mv	s0,a0
ffffffffc0200f12:	0017f713          	andi	a4,a5,1
ffffffffc0200f16:	e711                	bnez	a4,ffffffffc0200f22 <page_remove+0x26>
        page_remove_pte(pgdir, la, ptep);
    }
}
ffffffffc0200f18:	60e2                	ld	ra,24(sp)
ffffffffc0200f1a:	6442                	ld	s0,16(sp)
ffffffffc0200f1c:	64a2                	ld	s1,8(sp)
ffffffffc0200f1e:	6105                	addi	sp,sp,32
ffffffffc0200f20:	8082                	ret
    if (PPN(pa) >= npage) {
ffffffffc0200f22:	00014717          	auipc	a4,0x14
ffffffffc0200f26:	56670713          	addi	a4,a4,1382 # ffffffffc0215488 <npage>
ffffffffc0200f2a:	6318                	ld	a4,0(a4)
    return pa2page(PTE_ADDR(pte));
ffffffffc0200f2c:	078a                	slli	a5,a5,0x2
ffffffffc0200f2e:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc0200f30:	02e7fe63          	bleu	a4,a5,ffffffffc0200f6c <page_remove+0x70>
    return &pages[PPN(pa) - nbase];
ffffffffc0200f34:	00014717          	auipc	a4,0x14
ffffffffc0200f38:	5bc70713          	addi	a4,a4,1468 # ffffffffc02154f0 <pages>
ffffffffc0200f3c:	6308                	ld	a0,0(a4)
ffffffffc0200f3e:	fff80737          	lui	a4,0xfff80
ffffffffc0200f42:	97ba                	add	a5,a5,a4
ffffffffc0200f44:	079a                	slli	a5,a5,0x6
ffffffffc0200f46:	953e                	add	a0,a0,a5
    page->ref -= 1;
ffffffffc0200f48:	411c                	lw	a5,0(a0)
ffffffffc0200f4a:	fff7871b          	addiw	a4,a5,-1
ffffffffc0200f4e:	c118                	sw	a4,0(a0)
        if (page_ref(page) ==
ffffffffc0200f50:	cb11                	beqz	a4,ffffffffc0200f64 <page_remove+0x68>
        *ptep = 0;                  //(5) clear second page table entry
ffffffffc0200f52:	00043023          	sd	zero,0(s0)
// invalidate a TLB entry, but only if the page tables being
// edited are the ones currently in use by the processor.
void tlb_invalidate(pde_t *pgdir, uintptr_t la) {
    // flush_tlb();
    // The flush_tlb flush the entire TLB, is there any better way?
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc0200f56:	12048073          	sfence.vma	s1
}
ffffffffc0200f5a:	60e2                	ld	ra,24(sp)
ffffffffc0200f5c:	6442                	ld	s0,16(sp)
ffffffffc0200f5e:	64a2                	ld	s1,8(sp)
ffffffffc0200f60:	6105                	addi	sp,sp,32
ffffffffc0200f62:	8082                	ret
            free_page(page);
ffffffffc0200f64:	4585                	li	a1,1
ffffffffc0200f66:	cddff0ef          	jal	ra,ffffffffc0200c42 <free_pages>
ffffffffc0200f6a:	b7e5                	j	ffffffffc0200f52 <page_remove+0x56>
ffffffffc0200f6c:	c33ff0ef          	jal	ra,ffffffffc0200b9e <pa2page.part.4>

ffffffffc0200f70 <page_insert>:
int page_insert(pde_t *pgdir, struct Page *page, uintptr_t la, uint32_t perm) {
ffffffffc0200f70:	7179                	addi	sp,sp,-48
ffffffffc0200f72:	e44e                	sd	s3,8(sp)
ffffffffc0200f74:	89b2                	mv	s3,a2
ffffffffc0200f76:	f022                	sd	s0,32(sp)
    pte_t *ptep = get_pte(pgdir, la, 1);
ffffffffc0200f78:	4605                	li	a2,1
int page_insert(pde_t *pgdir, struct Page *page, uintptr_t la, uint32_t perm) {
ffffffffc0200f7a:	842e                	mv	s0,a1
    pte_t *ptep = get_pte(pgdir, la, 1);
ffffffffc0200f7c:	85ce                	mv	a1,s3
int page_insert(pde_t *pgdir, struct Page *page, uintptr_t la, uint32_t perm) {
ffffffffc0200f7e:	ec26                	sd	s1,24(sp)
ffffffffc0200f80:	f406                	sd	ra,40(sp)
ffffffffc0200f82:	e84a                	sd	s2,16(sp)
ffffffffc0200f84:	e052                	sd	s4,0(sp)
ffffffffc0200f86:	84b6                	mv	s1,a3
    pte_t *ptep = get_pte(pgdir, la, 1);
ffffffffc0200f88:	d41ff0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
    if (ptep == NULL) {
ffffffffc0200f8c:	cd49                	beqz	a0,ffffffffc0201026 <page_insert+0xb6>
    page->ref += 1;
ffffffffc0200f8e:	4014                	lw	a3,0(s0)
    if (*ptep & PTE_V) {
ffffffffc0200f90:	611c                	ld	a5,0(a0)
ffffffffc0200f92:	892a                	mv	s2,a0
ffffffffc0200f94:	0016871b          	addiw	a4,a3,1
ffffffffc0200f98:	c018                	sw	a4,0(s0)
ffffffffc0200f9a:	0017f713          	andi	a4,a5,1
ffffffffc0200f9e:	ef05                	bnez	a4,ffffffffc0200fd6 <page_insert+0x66>
ffffffffc0200fa0:	00014797          	auipc	a5,0x14
ffffffffc0200fa4:	55078793          	addi	a5,a5,1360 # ffffffffc02154f0 <pages>
ffffffffc0200fa8:	6398                	ld	a4,0(a5)
    return page - pages + nbase;
ffffffffc0200faa:	8c19                	sub	s0,s0,a4
ffffffffc0200fac:	000806b7          	lui	a3,0x80
ffffffffc0200fb0:	8419                	srai	s0,s0,0x6
ffffffffc0200fb2:	9436                	add	s0,s0,a3
  return (ppn << PTE_PPN_SHIFT) | PTE_V | type;
ffffffffc0200fb4:	042a                	slli	s0,s0,0xa
ffffffffc0200fb6:	8c45                	or	s0,s0,s1
ffffffffc0200fb8:	00146413          	ori	s0,s0,1
    *ptep = pte_create(page2ppn(page), PTE_V | perm);
ffffffffc0200fbc:	00893023          	sd	s0,0(s2)
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc0200fc0:	12098073          	sfence.vma	s3
    return 0;
ffffffffc0200fc4:	4501                	li	a0,0
}
ffffffffc0200fc6:	70a2                	ld	ra,40(sp)
ffffffffc0200fc8:	7402                	ld	s0,32(sp)
ffffffffc0200fca:	64e2                	ld	s1,24(sp)
ffffffffc0200fcc:	6942                	ld	s2,16(sp)
ffffffffc0200fce:	69a2                	ld	s3,8(sp)
ffffffffc0200fd0:	6a02                	ld	s4,0(sp)
ffffffffc0200fd2:	6145                	addi	sp,sp,48
ffffffffc0200fd4:	8082                	ret
    if (PPN(pa) >= npage) {
ffffffffc0200fd6:	00014717          	auipc	a4,0x14
ffffffffc0200fda:	4b270713          	addi	a4,a4,1202 # ffffffffc0215488 <npage>
ffffffffc0200fde:	6318                	ld	a4,0(a4)
    return pa2page(PTE_ADDR(pte));
ffffffffc0200fe0:	078a                	slli	a5,a5,0x2
ffffffffc0200fe2:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc0200fe4:	04e7f363          	bleu	a4,a5,ffffffffc020102a <page_insert+0xba>
    return &pages[PPN(pa) - nbase];
ffffffffc0200fe8:	00014a17          	auipc	s4,0x14
ffffffffc0200fec:	508a0a13          	addi	s4,s4,1288 # ffffffffc02154f0 <pages>
ffffffffc0200ff0:	000a3703          	ld	a4,0(s4)
ffffffffc0200ff4:	fff80537          	lui	a0,0xfff80
ffffffffc0200ff8:	953e                	add	a0,a0,a5
ffffffffc0200ffa:	051a                	slli	a0,a0,0x6
ffffffffc0200ffc:	953a                	add	a0,a0,a4
        if (p == page) {
ffffffffc0200ffe:	00a40a63          	beq	s0,a0,ffffffffc0201012 <page_insert+0xa2>
    page->ref -= 1;
ffffffffc0201002:	411c                	lw	a5,0(a0)
ffffffffc0201004:	fff7869b          	addiw	a3,a5,-1
ffffffffc0201008:	c114                	sw	a3,0(a0)
        if (page_ref(page) ==
ffffffffc020100a:	c691                	beqz	a3,ffffffffc0201016 <page_insert+0xa6>
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc020100c:	12098073          	sfence.vma	s3
ffffffffc0201010:	bf69                	j	ffffffffc0200faa <page_insert+0x3a>
ffffffffc0201012:	c014                	sw	a3,0(s0)
    return page->ref;
ffffffffc0201014:	bf59                	j	ffffffffc0200faa <page_insert+0x3a>
            free_page(page);
ffffffffc0201016:	4585                	li	a1,1
ffffffffc0201018:	c2bff0ef          	jal	ra,ffffffffc0200c42 <free_pages>
ffffffffc020101c:	000a3703          	ld	a4,0(s4)
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc0201020:	12098073          	sfence.vma	s3
ffffffffc0201024:	b759                	j	ffffffffc0200faa <page_insert+0x3a>
        return -E_NO_MEM;
ffffffffc0201026:	5571                	li	a0,-4
ffffffffc0201028:	bf79                	j	ffffffffc0200fc6 <page_insert+0x56>
ffffffffc020102a:	b75ff0ef          	jal	ra,ffffffffc0200b9e <pa2page.part.4>

ffffffffc020102e <pmm_init>:
    pmm_manager = &default_pmm_manager;
ffffffffc020102e:	00006797          	auipc	a5,0x6
ffffffffc0201032:	ad278793          	addi	a5,a5,-1326 # ffffffffc0206b00 <default_pmm_manager>
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc0201036:	638c                	ld	a1,0(a5)
void pmm_init(void) {
ffffffffc0201038:	715d                	addi	sp,sp,-80
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc020103a:	00005517          	auipc	a0,0x5
ffffffffc020103e:	87650513          	addi	a0,a0,-1930 # ffffffffc02058b0 <commands+0x8c0>
void pmm_init(void) {
ffffffffc0201042:	e486                	sd	ra,72(sp)
    pmm_manager = &default_pmm_manager;
ffffffffc0201044:	00014717          	auipc	a4,0x14
ffffffffc0201048:	48f73a23          	sd	a5,1172(a4) # ffffffffc02154d8 <pmm_manager>
void pmm_init(void) {
ffffffffc020104c:	e0a2                	sd	s0,64(sp)
ffffffffc020104e:	fc26                	sd	s1,56(sp)
ffffffffc0201050:	f84a                	sd	s2,48(sp)
ffffffffc0201052:	f44e                	sd	s3,40(sp)
ffffffffc0201054:	f052                	sd	s4,32(sp)
ffffffffc0201056:	ec56                	sd	s5,24(sp)
ffffffffc0201058:	e85a                	sd	s6,16(sp)
ffffffffc020105a:	e45e                	sd	s7,8(sp)
ffffffffc020105c:	e062                	sd	s8,0(sp)
    pmm_manager = &default_pmm_manager;
ffffffffc020105e:	00014417          	auipc	s0,0x14
ffffffffc0201062:	47a40413          	addi	s0,s0,1146 # ffffffffc02154d8 <pmm_manager>
    cprintf("memory management: %s\n", pmm_manager->name);
ffffffffc0201066:	86aff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    pmm_manager->init();
ffffffffc020106a:	601c                	ld	a5,0(s0)
ffffffffc020106c:	00014497          	auipc	s1,0x14
ffffffffc0201070:	41c48493          	addi	s1,s1,1052 # ffffffffc0215488 <npage>
ffffffffc0201074:	00014917          	auipc	s2,0x14
ffffffffc0201078:	47c90913          	addi	s2,s2,1148 # ffffffffc02154f0 <pages>
ffffffffc020107c:	679c                	ld	a5,8(a5)
ffffffffc020107e:	9782                	jalr	a5
    va_pa_offset = KERNBASE - 0x80200000;
ffffffffc0201080:	57f5                	li	a5,-3
ffffffffc0201082:	07fa                	slli	a5,a5,0x1e
    cprintf("physcial memory map:\n");
ffffffffc0201084:	00005517          	auipc	a0,0x5
ffffffffc0201088:	84450513          	addi	a0,a0,-1980 # ffffffffc02058c8 <commands+0x8d8>
    va_pa_offset = KERNBASE - 0x80200000;
ffffffffc020108c:	00014717          	auipc	a4,0x14
ffffffffc0201090:	44f73a23          	sd	a5,1108(a4) # ffffffffc02154e0 <va_pa_offset>
    cprintf("physcial memory map:\n");
ffffffffc0201094:	83cff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("  memory: 0x%08lx, [0x%08lx, 0x%08lx].\n", mem_size, mem_begin,
ffffffffc0201098:	46c5                	li	a3,17
ffffffffc020109a:	06ee                	slli	a3,a3,0x1b
ffffffffc020109c:	40100613          	li	a2,1025
ffffffffc02010a0:	16fd                	addi	a3,a3,-1
ffffffffc02010a2:	0656                	slli	a2,a2,0x15
ffffffffc02010a4:	07e005b7          	lui	a1,0x7e00
ffffffffc02010a8:	00005517          	auipc	a0,0x5
ffffffffc02010ac:	83850513          	addi	a0,a0,-1992 # ffffffffc02058e0 <commands+0x8f0>
ffffffffc02010b0:	820ff0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
ffffffffc02010b4:	777d                	lui	a4,0xfffff
ffffffffc02010b6:	00015797          	auipc	a5,0x15
ffffffffc02010ba:	54978793          	addi	a5,a5,1353 # ffffffffc02165ff <end+0xfff>
ffffffffc02010be:	8ff9                	and	a5,a5,a4
    npage = maxpa / PGSIZE;
ffffffffc02010c0:	00088737          	lui	a4,0x88
ffffffffc02010c4:	00014697          	auipc	a3,0x14
ffffffffc02010c8:	3ce6b223          	sd	a4,964(a3) # ffffffffc0215488 <npage>
    pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
ffffffffc02010cc:	00014717          	auipc	a4,0x14
ffffffffc02010d0:	42f73223          	sd	a5,1060(a4) # ffffffffc02154f0 <pages>
    for (size_t i = 0; i < npage - nbase; i++) {
ffffffffc02010d4:	4701                	li	a4,0
 *
 * Note that @nr may be almost arbitrarily large; this function is not
 * restricted to acting on a single-word quantity.
 * */
static inline void set_bit(int nr, volatile void *addr) {
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc02010d6:	4685                	li	a3,1
ffffffffc02010d8:	fff80837          	lui	a6,0xfff80
ffffffffc02010dc:	a019                	j	ffffffffc02010e2 <pmm_init+0xb4>
ffffffffc02010de:	00093783          	ld	a5,0(s2)
        SetPageReserved(pages + i);
ffffffffc02010e2:	00671613          	slli	a2,a4,0x6
ffffffffc02010e6:	97b2                	add	a5,a5,a2
ffffffffc02010e8:	07a1                	addi	a5,a5,8
ffffffffc02010ea:	40d7b02f          	amoor.d	zero,a3,(a5)
    for (size_t i = 0; i < npage - nbase; i++) {
ffffffffc02010ee:	6090                	ld	a2,0(s1)
ffffffffc02010f0:	0705                	addi	a4,a4,1
ffffffffc02010f2:	010607b3          	add	a5,a2,a6
ffffffffc02010f6:	fef764e3          	bltu	a4,a5,ffffffffc02010de <pmm_init+0xb0>
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc02010fa:	00093503          	ld	a0,0(s2)
ffffffffc02010fe:	fe0007b7          	lui	a5,0xfe000
ffffffffc0201102:	00661693          	slli	a3,a2,0x6
ffffffffc0201106:	97aa                	add	a5,a5,a0
ffffffffc0201108:	96be                	add	a3,a3,a5
ffffffffc020110a:	c02007b7          	lui	a5,0xc0200
ffffffffc020110e:	7af6ed63          	bltu	a3,a5,ffffffffc02018c8 <pmm_init+0x89a>
ffffffffc0201112:	00014997          	auipc	s3,0x14
ffffffffc0201116:	3ce98993          	addi	s3,s3,974 # ffffffffc02154e0 <va_pa_offset>
ffffffffc020111a:	0009b583          	ld	a1,0(s3)
    if (freemem < mem_end) {
ffffffffc020111e:	47c5                	li	a5,17
ffffffffc0201120:	07ee                	slli	a5,a5,0x1b
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc0201122:	8e8d                	sub	a3,a3,a1
    if (freemem < mem_end) {
ffffffffc0201124:	02f6f763          	bleu	a5,a3,ffffffffc0201152 <pmm_init+0x124>
    mem_begin = ROUNDUP(freemem, PGSIZE);
ffffffffc0201128:	6585                	lui	a1,0x1
ffffffffc020112a:	15fd                	addi	a1,a1,-1
ffffffffc020112c:	96ae                	add	a3,a3,a1
    if (PPN(pa) >= npage) {
ffffffffc020112e:	00c6d713          	srli	a4,a3,0xc
ffffffffc0201132:	48c77a63          	bleu	a2,a4,ffffffffc02015c6 <pmm_init+0x598>
    pmm_manager->init_memmap(base, n);
ffffffffc0201136:	6010                	ld	a2,0(s0)
        init_memmap(pa2page(mem_begin), (mem_end - mem_begin) / PGSIZE);
ffffffffc0201138:	75fd                	lui	a1,0xfffff
ffffffffc020113a:	8eed                	and	a3,a3,a1
    return &pages[PPN(pa) - nbase];
ffffffffc020113c:	9742                	add	a4,a4,a6
    pmm_manager->init_memmap(base, n);
ffffffffc020113e:	6a10                	ld	a2,16(a2)
        init_memmap(pa2page(mem_begin), (mem_end - mem_begin) / PGSIZE);
ffffffffc0201140:	40d786b3          	sub	a3,a5,a3
ffffffffc0201144:	071a                	slli	a4,a4,0x6
    pmm_manager->init_memmap(base, n);
ffffffffc0201146:	00c6d593          	srli	a1,a3,0xc
ffffffffc020114a:	953a                	add	a0,a0,a4
ffffffffc020114c:	9602                	jalr	a2
ffffffffc020114e:	0009b583          	ld	a1,0(s3)
    cprintf("vapaofset is %llu\n",va_pa_offset);
ffffffffc0201152:	00004517          	auipc	a0,0x4
ffffffffc0201156:	7de50513          	addi	a0,a0,2014 # ffffffffc0205930 <commands+0x940>
ffffffffc020115a:	f77fe0ef          	jal	ra,ffffffffc02000d0 <cprintf>

    return page;
}

static void check_alloc_page(void) {
    pmm_manager->check();
ffffffffc020115e:	601c                	ld	a5,0(s0)
    boot_pgdir = (pte_t*)boot_page_table_sv39;
ffffffffc0201160:	00014417          	auipc	s0,0x14
ffffffffc0201164:	32040413          	addi	s0,s0,800 # ffffffffc0215480 <boot_pgdir>
    pmm_manager->check();
ffffffffc0201168:	7b9c                	ld	a5,48(a5)
ffffffffc020116a:	9782                	jalr	a5
    cprintf("check_alloc_page() succeeded!\n");
ffffffffc020116c:	00004517          	auipc	a0,0x4
ffffffffc0201170:	7dc50513          	addi	a0,a0,2012 # ffffffffc0205948 <commands+0x958>
ffffffffc0201174:	f5dfe0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    boot_pgdir = (pte_t*)boot_page_table_sv39;
ffffffffc0201178:	00008697          	auipc	a3,0x8
ffffffffc020117c:	e8868693          	addi	a3,a3,-376 # ffffffffc0209000 <boot_page_table_sv39>
ffffffffc0201180:	00014797          	auipc	a5,0x14
ffffffffc0201184:	30d7b023          	sd	a3,768(a5) # ffffffffc0215480 <boot_pgdir>
    boot_cr3 = PADDR(boot_pgdir);
ffffffffc0201188:	c02007b7          	lui	a5,0xc0200
ffffffffc020118c:	10f6eae3          	bltu	a3,a5,ffffffffc0201aa0 <pmm_init+0xa72>
ffffffffc0201190:	0009b783          	ld	a5,0(s3)
ffffffffc0201194:	8e9d                	sub	a3,a3,a5
ffffffffc0201196:	00014797          	auipc	a5,0x14
ffffffffc020119a:	34d7b923          	sd	a3,850(a5) # ffffffffc02154e8 <boot_cr3>
    // assert(npage <= KMEMSIZE / PGSIZE);
    // The memory starts at 2GB in RISC-V
    // so npage is always larger than KMEMSIZE / PGSIZE
    size_t nr_free_store;

    nr_free_store=nr_free_pages();
ffffffffc020119e:	aebff0ef          	jal	ra,ffffffffc0200c88 <nr_free_pages>

    assert(npage <= KERNTOP / PGSIZE);
ffffffffc02011a2:	6098                	ld	a4,0(s1)
ffffffffc02011a4:	c80007b7          	lui	a5,0xc8000
ffffffffc02011a8:	83b1                	srli	a5,a5,0xc
    nr_free_store=nr_free_pages();
ffffffffc02011aa:	8a2a                	mv	s4,a0
    assert(npage <= KERNTOP / PGSIZE);
ffffffffc02011ac:	0ce7eae3          	bltu	a5,a4,ffffffffc0201a80 <pmm_init+0xa52>
    assert(boot_pgdir != NULL && (uint32_t)PGOFF(boot_pgdir) == 0);
ffffffffc02011b0:	6008                	ld	a0,0(s0)
ffffffffc02011b2:	44050463          	beqz	a0,ffffffffc02015fa <pmm_init+0x5cc>
ffffffffc02011b6:	6785                	lui	a5,0x1
ffffffffc02011b8:	17fd                	addi	a5,a5,-1
ffffffffc02011ba:	8fe9                	and	a5,a5,a0
ffffffffc02011bc:	2781                	sext.w	a5,a5
ffffffffc02011be:	42079e63          	bnez	a5,ffffffffc02015fa <pmm_init+0x5cc>
    assert(get_page(boot_pgdir, 0x0, NULL) == NULL);
ffffffffc02011c2:	4601                	li	a2,0
ffffffffc02011c4:	4581                	li	a1,0
ffffffffc02011c6:	cd5ff0ef          	jal	ra,ffffffffc0200e9a <get_page>
ffffffffc02011ca:	78051b63          	bnez	a0,ffffffffc0201960 <pmm_init+0x932>

    struct Page *p1, *p2;
    p1 = alloc_page();
ffffffffc02011ce:	4505                	li	a0,1
ffffffffc02011d0:	9ebff0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02011d4:	8aaa                	mv	s5,a0
    assert(page_insert(boot_pgdir, p1, 0x0, 0) == 0);
ffffffffc02011d6:	6008                	ld	a0,0(s0)
ffffffffc02011d8:	4681                	li	a3,0
ffffffffc02011da:	4601                	li	a2,0
ffffffffc02011dc:	85d6                	mv	a1,s5
ffffffffc02011de:	d93ff0ef          	jal	ra,ffffffffc0200f70 <page_insert>
ffffffffc02011e2:	7a051f63          	bnez	a0,ffffffffc02019a0 <pmm_init+0x972>

    pte_t *ptep;
    assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL);
ffffffffc02011e6:	6008                	ld	a0,0(s0)
ffffffffc02011e8:	4601                	li	a2,0
ffffffffc02011ea:	4581                	li	a1,0
ffffffffc02011ec:	addff0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
ffffffffc02011f0:	78050863          	beqz	a0,ffffffffc0201980 <pmm_init+0x952>
    assert(pte2page(*ptep) == p1);
ffffffffc02011f4:	611c                	ld	a5,0(a0)
    if (!(pte & PTE_V)) {
ffffffffc02011f6:	0017f713          	andi	a4,a5,1
ffffffffc02011fa:	3e070463          	beqz	a4,ffffffffc02015e2 <pmm_init+0x5b4>
    if (PPN(pa) >= npage) {
ffffffffc02011fe:	6098                	ld	a4,0(s1)
    return pa2page(PTE_ADDR(pte));
ffffffffc0201200:	078a                	slli	a5,a5,0x2
ffffffffc0201202:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc0201204:	3ce7f163          	bleu	a4,a5,ffffffffc02015c6 <pmm_init+0x598>
    return &pages[PPN(pa) - nbase];
ffffffffc0201208:	00093683          	ld	a3,0(s2)
ffffffffc020120c:	fff80637          	lui	a2,0xfff80
ffffffffc0201210:	97b2                	add	a5,a5,a2
ffffffffc0201212:	079a                	slli	a5,a5,0x6
ffffffffc0201214:	97b6                	add	a5,a5,a3
ffffffffc0201216:	72fa9563          	bne	s5,a5,ffffffffc0201940 <pmm_init+0x912>
    assert(page_ref(p1) == 1);
ffffffffc020121a:	000aab83          	lw	s7,0(s5)
ffffffffc020121e:	4785                	li	a5,1
ffffffffc0201220:	70fb9063          	bne	s7,a5,ffffffffc0201920 <pmm_init+0x8f2>

    ptep = (pte_t *)KADDR(PDE_ADDR(boot_pgdir[0]));
ffffffffc0201224:	6008                	ld	a0,0(s0)
ffffffffc0201226:	76fd                	lui	a3,0xfffff
ffffffffc0201228:	611c                	ld	a5,0(a0)
ffffffffc020122a:	078a                	slli	a5,a5,0x2
ffffffffc020122c:	8ff5                	and	a5,a5,a3
ffffffffc020122e:	00c7d613          	srli	a2,a5,0xc
ffffffffc0201232:	66e67e63          	bleu	a4,a2,ffffffffc02018ae <pmm_init+0x880>
ffffffffc0201236:	0009bc03          	ld	s8,0(s3)
    ptep = (pte_t *)KADDR(PDE_ADDR(ptep[0])) + 1;
ffffffffc020123a:	97e2                	add	a5,a5,s8
ffffffffc020123c:	0007bb03          	ld	s6,0(a5) # 1000 <BASE_ADDRESS-0xffffffffc01ff000>
ffffffffc0201240:	0b0a                	slli	s6,s6,0x2
ffffffffc0201242:	00db7b33          	and	s6,s6,a3
ffffffffc0201246:	00cb5793          	srli	a5,s6,0xc
ffffffffc020124a:	56e7f863          	bleu	a4,a5,ffffffffc02017ba <pmm_init+0x78c>
    assert(get_pte(boot_pgdir, PGSIZE, 0) == ptep);
ffffffffc020124e:	4601                	li	a2,0
ffffffffc0201250:	6585                	lui	a1,0x1
    ptep = (pte_t *)KADDR(PDE_ADDR(ptep[0])) + 1;
ffffffffc0201252:	9b62                	add	s6,s6,s8
    assert(get_pte(boot_pgdir, PGSIZE, 0) == ptep);
ffffffffc0201254:	a75ff0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
    ptep = (pte_t *)KADDR(PDE_ADDR(ptep[0])) + 1;
ffffffffc0201258:	0b21                	addi	s6,s6,8
    assert(get_pte(boot_pgdir, PGSIZE, 0) == ptep);
ffffffffc020125a:	55651063          	bne	a0,s6,ffffffffc020179a <pmm_init+0x76c>

    p2 = alloc_page();
ffffffffc020125e:	4505                	li	a0,1
ffffffffc0201260:	95bff0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0201264:	8b2a                	mv	s6,a0
    assert(page_insert(boot_pgdir, p2, PGSIZE, PTE_U | PTE_W) == 0);
ffffffffc0201266:	6008                	ld	a0,0(s0)
ffffffffc0201268:	46d1                	li	a3,20
ffffffffc020126a:	6605                	lui	a2,0x1
ffffffffc020126c:	85da                	mv	a1,s6
ffffffffc020126e:	d03ff0ef          	jal	ra,ffffffffc0200f70 <page_insert>
ffffffffc0201272:	50051463          	bnez	a0,ffffffffc020177a <pmm_init+0x74c>
    assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL);
ffffffffc0201276:	6008                	ld	a0,0(s0)
ffffffffc0201278:	4601                	li	a2,0
ffffffffc020127a:	6585                	lui	a1,0x1
ffffffffc020127c:	a4dff0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
ffffffffc0201280:	4c050d63          	beqz	a0,ffffffffc020175a <pmm_init+0x72c>
    assert(*ptep & PTE_U);
ffffffffc0201284:	611c                	ld	a5,0(a0)
ffffffffc0201286:	0107f713          	andi	a4,a5,16
ffffffffc020128a:	4a070863          	beqz	a4,ffffffffc020173a <pmm_init+0x70c>
    assert(*ptep & PTE_W);
ffffffffc020128e:	8b91                	andi	a5,a5,4
ffffffffc0201290:	48078563          	beqz	a5,ffffffffc020171a <pmm_init+0x6ec>
    assert(boot_pgdir[0] & PTE_U);
ffffffffc0201294:	6008                	ld	a0,0(s0)
ffffffffc0201296:	611c                	ld	a5,0(a0)
ffffffffc0201298:	8bc1                	andi	a5,a5,16
ffffffffc020129a:	46078063          	beqz	a5,ffffffffc02016fa <pmm_init+0x6cc>
    assert(page_ref(p2) == 1);
ffffffffc020129e:	000b2783          	lw	a5,0(s6)
ffffffffc02012a2:	43779c63          	bne	a5,s7,ffffffffc02016da <pmm_init+0x6ac>

    assert(page_insert(boot_pgdir, p1, PGSIZE, 0) == 0);
ffffffffc02012a6:	4681                	li	a3,0
ffffffffc02012a8:	6605                	lui	a2,0x1
ffffffffc02012aa:	85d6                	mv	a1,s5
ffffffffc02012ac:	cc5ff0ef          	jal	ra,ffffffffc0200f70 <page_insert>
ffffffffc02012b0:	40051563          	bnez	a0,ffffffffc02016ba <pmm_init+0x68c>
    assert(page_ref(p1) == 2);
ffffffffc02012b4:	000aa703          	lw	a4,0(s5)
ffffffffc02012b8:	4789                	li	a5,2
ffffffffc02012ba:	3ef71063          	bne	a4,a5,ffffffffc020169a <pmm_init+0x66c>
    assert(page_ref(p2) == 0);
ffffffffc02012be:	000b2783          	lw	a5,0(s6)
ffffffffc02012c2:	3a079c63          	bnez	a5,ffffffffc020167a <pmm_init+0x64c>
    assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL);
ffffffffc02012c6:	6008                	ld	a0,0(s0)
ffffffffc02012c8:	4601                	li	a2,0
ffffffffc02012ca:	6585                	lui	a1,0x1
ffffffffc02012cc:	9fdff0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
ffffffffc02012d0:	38050563          	beqz	a0,ffffffffc020165a <pmm_init+0x62c>
    assert(pte2page(*ptep) == p1);
ffffffffc02012d4:	6118                	ld	a4,0(a0)
    if (!(pte & PTE_V)) {
ffffffffc02012d6:	00177793          	andi	a5,a4,1
ffffffffc02012da:	30078463          	beqz	a5,ffffffffc02015e2 <pmm_init+0x5b4>
    if (PPN(pa) >= npage) {
ffffffffc02012de:	6094                	ld	a3,0(s1)
    return pa2page(PTE_ADDR(pte));
ffffffffc02012e0:	00271793          	slli	a5,a4,0x2
ffffffffc02012e4:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc02012e6:	2ed7f063          	bleu	a3,a5,ffffffffc02015c6 <pmm_init+0x598>
    return &pages[PPN(pa) - nbase];
ffffffffc02012ea:	00093683          	ld	a3,0(s2)
ffffffffc02012ee:	fff80637          	lui	a2,0xfff80
ffffffffc02012f2:	97b2                	add	a5,a5,a2
ffffffffc02012f4:	079a                	slli	a5,a5,0x6
ffffffffc02012f6:	97b6                	add	a5,a5,a3
ffffffffc02012f8:	32fa9163          	bne	s5,a5,ffffffffc020161a <pmm_init+0x5ec>
    assert((*ptep & PTE_U) == 0);
ffffffffc02012fc:	8b41                	andi	a4,a4,16
ffffffffc02012fe:	70071163          	bnez	a4,ffffffffc0201a00 <pmm_init+0x9d2>

    page_remove(boot_pgdir, 0x0);
ffffffffc0201302:	6008                	ld	a0,0(s0)
ffffffffc0201304:	4581                	li	a1,0
ffffffffc0201306:	bf7ff0ef          	jal	ra,ffffffffc0200efc <page_remove>
    assert(page_ref(p1) == 1);
ffffffffc020130a:	000aa703          	lw	a4,0(s5)
ffffffffc020130e:	4785                	li	a5,1
ffffffffc0201310:	6cf71863          	bne	a4,a5,ffffffffc02019e0 <pmm_init+0x9b2>
    assert(page_ref(p2) == 0);
ffffffffc0201314:	000b2783          	lw	a5,0(s6)
ffffffffc0201318:	6a079463          	bnez	a5,ffffffffc02019c0 <pmm_init+0x992>

    page_remove(boot_pgdir, PGSIZE);
ffffffffc020131c:	6008                	ld	a0,0(s0)
ffffffffc020131e:	6585                	lui	a1,0x1
ffffffffc0201320:	bddff0ef          	jal	ra,ffffffffc0200efc <page_remove>
    assert(page_ref(p1) == 0);
ffffffffc0201324:	000aa783          	lw	a5,0(s5)
ffffffffc0201328:	50079363          	bnez	a5,ffffffffc020182e <pmm_init+0x800>
    assert(page_ref(p2) == 0);
ffffffffc020132c:	000b2783          	lw	a5,0(s6)
ffffffffc0201330:	4c079f63          	bnez	a5,ffffffffc020180e <pmm_init+0x7e0>

    assert(page_ref(pde2page(boot_pgdir[0])) == 1);
ffffffffc0201334:	00043a83          	ld	s5,0(s0)
    if (PPN(pa) >= npage) {
ffffffffc0201338:	6090                	ld	a2,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc020133a:	000ab783          	ld	a5,0(s5)
ffffffffc020133e:	078a                	slli	a5,a5,0x2
ffffffffc0201340:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc0201342:	28c7f263          	bleu	a2,a5,ffffffffc02015c6 <pmm_init+0x598>
    return &pages[PPN(pa) - nbase];
ffffffffc0201346:	fff80737          	lui	a4,0xfff80
ffffffffc020134a:	00093503          	ld	a0,0(s2)
ffffffffc020134e:	97ba                	add	a5,a5,a4
ffffffffc0201350:	079a                	slli	a5,a5,0x6
ffffffffc0201352:	00f50733          	add	a4,a0,a5
ffffffffc0201356:	4314                	lw	a3,0(a4)
ffffffffc0201358:	4705                	li	a4,1
ffffffffc020135a:	48e69a63          	bne	a3,a4,ffffffffc02017ee <pmm_init+0x7c0>
    return page - pages + nbase;
ffffffffc020135e:	8799                	srai	a5,a5,0x6
ffffffffc0201360:	00080b37          	lui	s6,0x80
    return KADDR(page2pa(page));
ffffffffc0201364:	577d                	li	a4,-1
    return page - pages + nbase;
ffffffffc0201366:	97da                	add	a5,a5,s6
    return KADDR(page2pa(page));
ffffffffc0201368:	8331                	srli	a4,a4,0xc
ffffffffc020136a:	8f7d                	and	a4,a4,a5
    return page2ppn(page) << PGSHIFT;
ffffffffc020136c:	07b2                	slli	a5,a5,0xc
    return KADDR(page2pa(page));
ffffffffc020136e:	46c77363          	bleu	a2,a4,ffffffffc02017d4 <pmm_init+0x7a6>

    pde_t *pd1=boot_pgdir,*pd0=page2kva(pde2page(boot_pgdir[0]));
    free_page(pde2page(pd0[0]));
ffffffffc0201372:	0009b683          	ld	a3,0(s3)
ffffffffc0201376:	97b6                	add	a5,a5,a3
    return pa2page(PDE_ADDR(pde));
ffffffffc0201378:	639c                	ld	a5,0(a5)
ffffffffc020137a:	078a                	slli	a5,a5,0x2
ffffffffc020137c:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc020137e:	24c7f463          	bleu	a2,a5,ffffffffc02015c6 <pmm_init+0x598>
    return &pages[PPN(pa) - nbase];
ffffffffc0201382:	416787b3          	sub	a5,a5,s6
ffffffffc0201386:	079a                	slli	a5,a5,0x6
ffffffffc0201388:	953e                	add	a0,a0,a5
ffffffffc020138a:	4585                	li	a1,1
ffffffffc020138c:	8b7ff0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    return pa2page(PDE_ADDR(pde));
ffffffffc0201390:	000ab783          	ld	a5,0(s5)
    if (PPN(pa) >= npage) {
ffffffffc0201394:	6098                	ld	a4,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc0201396:	078a                	slli	a5,a5,0x2
ffffffffc0201398:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc020139a:	22e7f663          	bleu	a4,a5,ffffffffc02015c6 <pmm_init+0x598>
    return &pages[PPN(pa) - nbase];
ffffffffc020139e:	00093503          	ld	a0,0(s2)
ffffffffc02013a2:	416787b3          	sub	a5,a5,s6
ffffffffc02013a6:	079a                	slli	a5,a5,0x6
    free_page(pde2page(pd1[0]));
ffffffffc02013a8:	953e                	add	a0,a0,a5
ffffffffc02013aa:	4585                	li	a1,1
ffffffffc02013ac:	897ff0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    boot_pgdir[0] = 0;
ffffffffc02013b0:	601c                	ld	a5,0(s0)
ffffffffc02013b2:	0007b023          	sd	zero,0(a5)
  asm volatile("sfence.vma");
ffffffffc02013b6:	12000073          	sfence.vma
    flush_tlb();

    assert(nr_free_store==nr_free_pages());
ffffffffc02013ba:	8cfff0ef          	jal	ra,ffffffffc0200c88 <nr_free_pages>
ffffffffc02013be:	68aa1163          	bne	s4,a0,ffffffffc0201a40 <pmm_init+0xa12>

    cprintf("check_pgdir() succeeded!\n");
ffffffffc02013c2:	00005517          	auipc	a0,0x5
ffffffffc02013c6:	8ae50513          	addi	a0,a0,-1874 # ffffffffc0205c70 <commands+0xc80>
ffffffffc02013ca:	d07fe0ef          	jal	ra,ffffffffc02000d0 <cprintf>
static void check_boot_pgdir(void) {
    size_t nr_free_store;
    pte_t *ptep;
    int i;

    nr_free_store=nr_free_pages();
ffffffffc02013ce:	8bbff0ef          	jal	ra,ffffffffc0200c88 <nr_free_pages>

    for (i = ROUNDDOWN(KERNBASE, PGSIZE); i < npage * PGSIZE; i += PGSIZE) {
ffffffffc02013d2:	6098                	ld	a4,0(s1)
ffffffffc02013d4:	c02007b7          	lui	a5,0xc0200
    nr_free_store=nr_free_pages();
ffffffffc02013d8:	8a2a                	mv	s4,a0
    for (i = ROUNDDOWN(KERNBASE, PGSIZE); i < npage * PGSIZE; i += PGSIZE) {
ffffffffc02013da:	00c71693          	slli	a3,a4,0xc
ffffffffc02013de:	18d7f563          	bleu	a3,a5,ffffffffc0201568 <pmm_init+0x53a>
        assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL);
ffffffffc02013e2:	83b1                	srli	a5,a5,0xc
ffffffffc02013e4:	6008                	ld	a0,0(s0)
    for (i = ROUNDDOWN(KERNBASE, PGSIZE); i < npage * PGSIZE; i += PGSIZE) {
ffffffffc02013e6:	c0200ab7          	lui	s5,0xc0200
        assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL);
ffffffffc02013ea:	1ae7f163          	bleu	a4,a5,ffffffffc020158c <pmm_init+0x55e>
        assert(PTE_ADDR(*ptep) == i);
ffffffffc02013ee:	7bfd                	lui	s7,0xfffff
ffffffffc02013f0:	6b05                	lui	s6,0x1
ffffffffc02013f2:	a029                	j	ffffffffc02013fc <pmm_init+0x3ce>
        assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL);
ffffffffc02013f4:	00cad713          	srli	a4,s5,0xc
ffffffffc02013f8:	18f77a63          	bleu	a5,a4,ffffffffc020158c <pmm_init+0x55e>
ffffffffc02013fc:	0009b583          	ld	a1,0(s3)
ffffffffc0201400:	4601                	li	a2,0
ffffffffc0201402:	95d6                	add	a1,a1,s5
ffffffffc0201404:	8c5ff0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
ffffffffc0201408:	16050263          	beqz	a0,ffffffffc020156c <pmm_init+0x53e>
        assert(PTE_ADDR(*ptep) == i);
ffffffffc020140c:	611c                	ld	a5,0(a0)
ffffffffc020140e:	078a                	slli	a5,a5,0x2
ffffffffc0201410:	0177f7b3          	and	a5,a5,s7
ffffffffc0201414:	19579963          	bne	a5,s5,ffffffffc02015a6 <pmm_init+0x578>
    for (i = ROUNDDOWN(KERNBASE, PGSIZE); i < npage * PGSIZE; i += PGSIZE) {
ffffffffc0201418:	609c                	ld	a5,0(s1)
ffffffffc020141a:	9ada                	add	s5,s5,s6
ffffffffc020141c:	6008                	ld	a0,0(s0)
ffffffffc020141e:	00c79713          	slli	a4,a5,0xc
ffffffffc0201422:	fceae9e3          	bltu	s5,a4,ffffffffc02013f4 <pmm_init+0x3c6>
    }

    assert(boot_pgdir[0] == 0);
ffffffffc0201426:	611c                	ld	a5,0(a0)
ffffffffc0201428:	62079c63          	bnez	a5,ffffffffc0201a60 <pmm_init+0xa32>

    struct Page *p;
    p = alloc_page();
ffffffffc020142c:	4505                	li	a0,1
ffffffffc020142e:	f8cff0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0201432:	8aaa                	mv	s5,a0
    assert(page_insert(boot_pgdir, p, 0x100, PTE_W | PTE_R) == 0);
ffffffffc0201434:	6008                	ld	a0,0(s0)
ffffffffc0201436:	4699                	li	a3,6
ffffffffc0201438:	10000613          	li	a2,256
ffffffffc020143c:	85d6                	mv	a1,s5
ffffffffc020143e:	b33ff0ef          	jal	ra,ffffffffc0200f70 <page_insert>
ffffffffc0201442:	1e051c63          	bnez	a0,ffffffffc020163a <pmm_init+0x60c>
    assert(page_ref(p) == 1);
ffffffffc0201446:	000aa703          	lw	a4,0(s5) # ffffffffc0200000 <kern_entry>
ffffffffc020144a:	4785                	li	a5,1
ffffffffc020144c:	44f71163          	bne	a4,a5,ffffffffc020188e <pmm_init+0x860>
    assert(page_insert(boot_pgdir, p, 0x100 + PGSIZE, PTE_W | PTE_R) == 0);
ffffffffc0201450:	6008                	ld	a0,0(s0)
ffffffffc0201452:	6b05                	lui	s6,0x1
ffffffffc0201454:	4699                	li	a3,6
ffffffffc0201456:	100b0613          	addi	a2,s6,256 # 1100 <BASE_ADDRESS-0xffffffffc01fef00>
ffffffffc020145a:	85d6                	mv	a1,s5
ffffffffc020145c:	b15ff0ef          	jal	ra,ffffffffc0200f70 <page_insert>
ffffffffc0201460:	40051763          	bnez	a0,ffffffffc020186e <pmm_init+0x840>
    assert(page_ref(p) == 2);
ffffffffc0201464:	000aa703          	lw	a4,0(s5)
ffffffffc0201468:	4789                	li	a5,2
ffffffffc020146a:	3ef71263          	bne	a4,a5,ffffffffc020184e <pmm_init+0x820>

    const char *str = "ucore: Hello world!!";
    strcpy((void *)0x100, str);
ffffffffc020146e:	00005597          	auipc	a1,0x5
ffffffffc0201472:	93a58593          	addi	a1,a1,-1734 # ffffffffc0205da8 <commands+0xdb8>
ffffffffc0201476:	10000513          	li	a0,256
ffffffffc020147a:	562030ef          	jal	ra,ffffffffc02049dc <strcpy>
    assert(strcmp((void *)0x100, (void *)(0x100 + PGSIZE)) == 0);
ffffffffc020147e:	100b0593          	addi	a1,s6,256
ffffffffc0201482:	10000513          	li	a0,256
ffffffffc0201486:	568030ef          	jal	ra,ffffffffc02049ee <strcmp>
ffffffffc020148a:	44051b63          	bnez	a0,ffffffffc02018e0 <pmm_init+0x8b2>
    return page - pages + nbase;
ffffffffc020148e:	00093683          	ld	a3,0(s2)
ffffffffc0201492:	00080737          	lui	a4,0x80
    return KADDR(page2pa(page));
ffffffffc0201496:	5b7d                	li	s6,-1
    return page - pages + nbase;
ffffffffc0201498:	40da86b3          	sub	a3,s5,a3
ffffffffc020149c:	8699                	srai	a3,a3,0x6
    return KADDR(page2pa(page));
ffffffffc020149e:	609c                	ld	a5,0(s1)
    return page - pages + nbase;
ffffffffc02014a0:	96ba                	add	a3,a3,a4
    return KADDR(page2pa(page));
ffffffffc02014a2:	00cb5b13          	srli	s6,s6,0xc
ffffffffc02014a6:	0166f733          	and	a4,a3,s6
    return page2ppn(page) << PGSHIFT;
ffffffffc02014aa:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc02014ac:	10f77f63          	bleu	a5,a4,ffffffffc02015ca <pmm_init+0x59c>

    *(char *)(page2kva(p) + 0x100) = '\0';
ffffffffc02014b0:	0009b783          	ld	a5,0(s3)
    assert(strlen((const char *)0x100) == 0);
ffffffffc02014b4:	10000513          	li	a0,256
    *(char *)(page2kva(p) + 0x100) = '\0';
ffffffffc02014b8:	96be                	add	a3,a3,a5
ffffffffc02014ba:	10068023          	sb	zero,256(a3) # fffffffffffff100 <end+0x3fde9b00>
    assert(strlen((const char *)0x100) == 0);
ffffffffc02014be:	4da030ef          	jal	ra,ffffffffc0204998 <strlen>
ffffffffc02014c2:	54051f63          	bnez	a0,ffffffffc0201a20 <pmm_init+0x9f2>

    pde_t *pd1=boot_pgdir,*pd0=page2kva(pde2page(boot_pgdir[0]));
ffffffffc02014c6:	00043b83          	ld	s7,0(s0)
    if (PPN(pa) >= npage) {
ffffffffc02014ca:	609c                	ld	a5,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc02014cc:	000bb683          	ld	a3,0(s7) # fffffffffffff000 <end+0x3fde9a00>
ffffffffc02014d0:	068a                	slli	a3,a3,0x2
ffffffffc02014d2:	82b1                	srli	a3,a3,0xc
    if (PPN(pa) >= npage) {
ffffffffc02014d4:	0ef6f963          	bleu	a5,a3,ffffffffc02015c6 <pmm_init+0x598>
    return KADDR(page2pa(page));
ffffffffc02014d8:	0166fb33          	and	s6,a3,s6
    return page2ppn(page) << PGSHIFT;
ffffffffc02014dc:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc02014de:	0efb7663          	bleu	a5,s6,ffffffffc02015ca <pmm_init+0x59c>
ffffffffc02014e2:	0009b983          	ld	s3,0(s3)
    free_page(p);
ffffffffc02014e6:	4585                	li	a1,1
ffffffffc02014e8:	8556                	mv	a0,s5
ffffffffc02014ea:	99b6                	add	s3,s3,a3
ffffffffc02014ec:	f56ff0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    return pa2page(PDE_ADDR(pde));
ffffffffc02014f0:	0009b783          	ld	a5,0(s3)
    if (PPN(pa) >= npage) {
ffffffffc02014f4:	6098                	ld	a4,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc02014f6:	078a                	slli	a5,a5,0x2
ffffffffc02014f8:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc02014fa:	0ce7f663          	bleu	a4,a5,ffffffffc02015c6 <pmm_init+0x598>
    return &pages[PPN(pa) - nbase];
ffffffffc02014fe:	00093503          	ld	a0,0(s2)
ffffffffc0201502:	fff809b7          	lui	s3,0xfff80
ffffffffc0201506:	97ce                	add	a5,a5,s3
ffffffffc0201508:	079a                	slli	a5,a5,0x6
    free_page(pde2page(pd0[0]));
ffffffffc020150a:	953e                	add	a0,a0,a5
ffffffffc020150c:	4585                	li	a1,1
ffffffffc020150e:	f34ff0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    return pa2page(PDE_ADDR(pde));
ffffffffc0201512:	000bb783          	ld	a5,0(s7)
    if (PPN(pa) >= npage) {
ffffffffc0201516:	6098                	ld	a4,0(s1)
    return pa2page(PDE_ADDR(pde));
ffffffffc0201518:	078a                	slli	a5,a5,0x2
ffffffffc020151a:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc020151c:	0ae7f563          	bleu	a4,a5,ffffffffc02015c6 <pmm_init+0x598>
    return &pages[PPN(pa) - nbase];
ffffffffc0201520:	00093503          	ld	a0,0(s2)
ffffffffc0201524:	97ce                	add	a5,a5,s3
ffffffffc0201526:	079a                	slli	a5,a5,0x6
    free_page(pde2page(pd1[0]));
ffffffffc0201528:	953e                	add	a0,a0,a5
ffffffffc020152a:	4585                	li	a1,1
ffffffffc020152c:	f16ff0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    boot_pgdir[0] = 0;
ffffffffc0201530:	601c                	ld	a5,0(s0)
ffffffffc0201532:	0007b023          	sd	zero,0(a5) # ffffffffc0200000 <kern_entry>
  asm volatile("sfence.vma");
ffffffffc0201536:	12000073          	sfence.vma
    flush_tlb();

    assert(nr_free_store==nr_free_pages());
ffffffffc020153a:	f4eff0ef          	jal	ra,ffffffffc0200c88 <nr_free_pages>
ffffffffc020153e:	3caa1163          	bne	s4,a0,ffffffffc0201900 <pmm_init+0x8d2>

    cprintf("check_boot_pgdir() succeeded!\n");
ffffffffc0201542:	00005517          	auipc	a0,0x5
ffffffffc0201546:	8de50513          	addi	a0,a0,-1826 # ffffffffc0205e20 <commands+0xe30>
ffffffffc020154a:	b87fe0ef          	jal	ra,ffffffffc02000d0 <cprintf>
}
ffffffffc020154e:	6406                	ld	s0,64(sp)
ffffffffc0201550:	60a6                	ld	ra,72(sp)
ffffffffc0201552:	74e2                	ld	s1,56(sp)
ffffffffc0201554:	7942                	ld	s2,48(sp)
ffffffffc0201556:	79a2                	ld	s3,40(sp)
ffffffffc0201558:	7a02                	ld	s4,32(sp)
ffffffffc020155a:	6ae2                	ld	s5,24(sp)
ffffffffc020155c:	6b42                	ld	s6,16(sp)
ffffffffc020155e:	6ba2                	ld	s7,8(sp)
ffffffffc0201560:	6c02                	ld	s8,0(sp)
ffffffffc0201562:	6161                	addi	sp,sp,80
    kmalloc_init();
ffffffffc0201564:	1c30106f          	j	ffffffffc0202f26 <kmalloc_init>
ffffffffc0201568:	6008                	ld	a0,0(s0)
ffffffffc020156a:	bd75                	j	ffffffffc0201426 <pmm_init+0x3f8>
        assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL);
ffffffffc020156c:	00004697          	auipc	a3,0x4
ffffffffc0201570:	72468693          	addi	a3,a3,1828 # ffffffffc0205c90 <commands+0xca0>
ffffffffc0201574:	00004617          	auipc	a2,0x4
ffffffffc0201578:	41460613          	addi	a2,a2,1044 # ffffffffc0205988 <commands+0x998>
ffffffffc020157c:	19d00593          	li	a1,413
ffffffffc0201580:	00004517          	auipc	a0,0x4
ffffffffc0201584:	2d850513          	addi	a0,a0,728 # ffffffffc0205858 <commands+0x868>
ffffffffc0201588:	c4ffe0ef          	jal	ra,ffffffffc02001d6 <__panic>
ffffffffc020158c:	86d6                	mv	a3,s5
ffffffffc020158e:	00004617          	auipc	a2,0x4
ffffffffc0201592:	2a260613          	addi	a2,a2,674 # ffffffffc0205830 <commands+0x840>
ffffffffc0201596:	19d00593          	li	a1,413
ffffffffc020159a:	00004517          	auipc	a0,0x4
ffffffffc020159e:	2be50513          	addi	a0,a0,702 # ffffffffc0205858 <commands+0x868>
ffffffffc02015a2:	c35fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(PTE_ADDR(*ptep) == i);
ffffffffc02015a6:	00004697          	auipc	a3,0x4
ffffffffc02015aa:	72a68693          	addi	a3,a3,1834 # ffffffffc0205cd0 <commands+0xce0>
ffffffffc02015ae:	00004617          	auipc	a2,0x4
ffffffffc02015b2:	3da60613          	addi	a2,a2,986 # ffffffffc0205988 <commands+0x998>
ffffffffc02015b6:	19e00593          	li	a1,414
ffffffffc02015ba:	00004517          	auipc	a0,0x4
ffffffffc02015be:	29e50513          	addi	a0,a0,670 # ffffffffc0205858 <commands+0x868>
ffffffffc02015c2:	c15fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
ffffffffc02015c6:	dd8ff0ef          	jal	ra,ffffffffc0200b9e <pa2page.part.4>
    return KADDR(page2pa(page));
ffffffffc02015ca:	00004617          	auipc	a2,0x4
ffffffffc02015ce:	26660613          	addi	a2,a2,614 # ffffffffc0205830 <commands+0x840>
ffffffffc02015d2:	06900593          	li	a1,105
ffffffffc02015d6:	00004517          	auipc	a0,0x4
ffffffffc02015da:	2b250513          	addi	a0,a0,690 # ffffffffc0205888 <commands+0x898>
ffffffffc02015de:	bf9fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        panic("pte2page called with invalid pte");
ffffffffc02015e2:	00004617          	auipc	a2,0x4
ffffffffc02015e6:	47e60613          	addi	a2,a2,1150 # ffffffffc0205a60 <commands+0xa70>
ffffffffc02015ea:	07400593          	li	a1,116
ffffffffc02015ee:	00004517          	auipc	a0,0x4
ffffffffc02015f2:	29a50513          	addi	a0,a0,666 # ffffffffc0205888 <commands+0x898>
ffffffffc02015f6:	be1fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(boot_pgdir != NULL && (uint32_t)PGOFF(boot_pgdir) == 0);
ffffffffc02015fa:	00004697          	auipc	a3,0x4
ffffffffc02015fe:	3a668693          	addi	a3,a3,934 # ffffffffc02059a0 <commands+0x9b0>
ffffffffc0201602:	00004617          	auipc	a2,0x4
ffffffffc0201606:	38660613          	addi	a2,a2,902 # ffffffffc0205988 <commands+0x998>
ffffffffc020160a:	16100593          	li	a1,353
ffffffffc020160e:	00004517          	auipc	a0,0x4
ffffffffc0201612:	24a50513          	addi	a0,a0,586 # ffffffffc0205858 <commands+0x868>
ffffffffc0201616:	bc1fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pte2page(*ptep) == p1);
ffffffffc020161a:	00004697          	auipc	a3,0x4
ffffffffc020161e:	46e68693          	addi	a3,a3,1134 # ffffffffc0205a88 <commands+0xa98>
ffffffffc0201622:	00004617          	auipc	a2,0x4
ffffffffc0201626:	36660613          	addi	a2,a2,870 # ffffffffc0205988 <commands+0x998>
ffffffffc020162a:	17d00593          	li	a1,381
ffffffffc020162e:	00004517          	auipc	a0,0x4
ffffffffc0201632:	22a50513          	addi	a0,a0,554 # ffffffffc0205858 <commands+0x868>
ffffffffc0201636:	ba1fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_insert(boot_pgdir, p, 0x100, PTE_W | PTE_R) == 0);
ffffffffc020163a:	00004697          	auipc	a3,0x4
ffffffffc020163e:	6c668693          	addi	a3,a3,1734 # ffffffffc0205d00 <commands+0xd10>
ffffffffc0201642:	00004617          	auipc	a2,0x4
ffffffffc0201646:	34660613          	addi	a2,a2,838 # ffffffffc0205988 <commands+0x998>
ffffffffc020164a:	1a500593          	li	a1,421
ffffffffc020164e:	00004517          	auipc	a0,0x4
ffffffffc0201652:	20a50513          	addi	a0,a0,522 # ffffffffc0205858 <commands+0x868>
ffffffffc0201656:	b81fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL);
ffffffffc020165a:	00004697          	auipc	a3,0x4
ffffffffc020165e:	4be68693          	addi	a3,a3,1214 # ffffffffc0205b18 <commands+0xb28>
ffffffffc0201662:	00004617          	auipc	a2,0x4
ffffffffc0201666:	32660613          	addi	a2,a2,806 # ffffffffc0205988 <commands+0x998>
ffffffffc020166a:	17c00593          	li	a1,380
ffffffffc020166e:	00004517          	auipc	a0,0x4
ffffffffc0201672:	1ea50513          	addi	a0,a0,490 # ffffffffc0205858 <commands+0x868>
ffffffffc0201676:	b61fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p2) == 0);
ffffffffc020167a:	00004697          	auipc	a3,0x4
ffffffffc020167e:	56668693          	addi	a3,a3,1382 # ffffffffc0205be0 <commands+0xbf0>
ffffffffc0201682:	00004617          	auipc	a2,0x4
ffffffffc0201686:	30660613          	addi	a2,a2,774 # ffffffffc0205988 <commands+0x998>
ffffffffc020168a:	17b00593          	li	a1,379
ffffffffc020168e:	00004517          	auipc	a0,0x4
ffffffffc0201692:	1ca50513          	addi	a0,a0,458 # ffffffffc0205858 <commands+0x868>
ffffffffc0201696:	b41fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p1) == 2);
ffffffffc020169a:	00004697          	auipc	a3,0x4
ffffffffc020169e:	52e68693          	addi	a3,a3,1326 # ffffffffc0205bc8 <commands+0xbd8>
ffffffffc02016a2:	00004617          	auipc	a2,0x4
ffffffffc02016a6:	2e660613          	addi	a2,a2,742 # ffffffffc0205988 <commands+0x998>
ffffffffc02016aa:	17a00593          	li	a1,378
ffffffffc02016ae:	00004517          	auipc	a0,0x4
ffffffffc02016b2:	1aa50513          	addi	a0,a0,426 # ffffffffc0205858 <commands+0x868>
ffffffffc02016b6:	b21fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_insert(boot_pgdir, p1, PGSIZE, 0) == 0);
ffffffffc02016ba:	00004697          	auipc	a3,0x4
ffffffffc02016be:	4de68693          	addi	a3,a3,1246 # ffffffffc0205b98 <commands+0xba8>
ffffffffc02016c2:	00004617          	auipc	a2,0x4
ffffffffc02016c6:	2c660613          	addi	a2,a2,710 # ffffffffc0205988 <commands+0x998>
ffffffffc02016ca:	17900593          	li	a1,377
ffffffffc02016ce:	00004517          	auipc	a0,0x4
ffffffffc02016d2:	18a50513          	addi	a0,a0,394 # ffffffffc0205858 <commands+0x868>
ffffffffc02016d6:	b01fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p2) == 1);
ffffffffc02016da:	00004697          	auipc	a3,0x4
ffffffffc02016de:	4a668693          	addi	a3,a3,1190 # ffffffffc0205b80 <commands+0xb90>
ffffffffc02016e2:	00004617          	auipc	a2,0x4
ffffffffc02016e6:	2a660613          	addi	a2,a2,678 # ffffffffc0205988 <commands+0x998>
ffffffffc02016ea:	17700593          	li	a1,375
ffffffffc02016ee:	00004517          	auipc	a0,0x4
ffffffffc02016f2:	16a50513          	addi	a0,a0,362 # ffffffffc0205858 <commands+0x868>
ffffffffc02016f6:	ae1fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(boot_pgdir[0] & PTE_U);
ffffffffc02016fa:	00004697          	auipc	a3,0x4
ffffffffc02016fe:	46e68693          	addi	a3,a3,1134 # ffffffffc0205b68 <commands+0xb78>
ffffffffc0201702:	00004617          	auipc	a2,0x4
ffffffffc0201706:	28660613          	addi	a2,a2,646 # ffffffffc0205988 <commands+0x998>
ffffffffc020170a:	17600593          	li	a1,374
ffffffffc020170e:	00004517          	auipc	a0,0x4
ffffffffc0201712:	14a50513          	addi	a0,a0,330 # ffffffffc0205858 <commands+0x868>
ffffffffc0201716:	ac1fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(*ptep & PTE_W);
ffffffffc020171a:	00004697          	auipc	a3,0x4
ffffffffc020171e:	43e68693          	addi	a3,a3,1086 # ffffffffc0205b58 <commands+0xb68>
ffffffffc0201722:	00004617          	auipc	a2,0x4
ffffffffc0201726:	26660613          	addi	a2,a2,614 # ffffffffc0205988 <commands+0x998>
ffffffffc020172a:	17500593          	li	a1,373
ffffffffc020172e:	00004517          	auipc	a0,0x4
ffffffffc0201732:	12a50513          	addi	a0,a0,298 # ffffffffc0205858 <commands+0x868>
ffffffffc0201736:	aa1fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(*ptep & PTE_U);
ffffffffc020173a:	00004697          	auipc	a3,0x4
ffffffffc020173e:	40e68693          	addi	a3,a3,1038 # ffffffffc0205b48 <commands+0xb58>
ffffffffc0201742:	00004617          	auipc	a2,0x4
ffffffffc0201746:	24660613          	addi	a2,a2,582 # ffffffffc0205988 <commands+0x998>
ffffffffc020174a:	17400593          	li	a1,372
ffffffffc020174e:	00004517          	auipc	a0,0x4
ffffffffc0201752:	10a50513          	addi	a0,a0,266 # ffffffffc0205858 <commands+0x868>
ffffffffc0201756:	a81fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL);
ffffffffc020175a:	00004697          	auipc	a3,0x4
ffffffffc020175e:	3be68693          	addi	a3,a3,958 # ffffffffc0205b18 <commands+0xb28>
ffffffffc0201762:	00004617          	auipc	a2,0x4
ffffffffc0201766:	22660613          	addi	a2,a2,550 # ffffffffc0205988 <commands+0x998>
ffffffffc020176a:	17300593          	li	a1,371
ffffffffc020176e:	00004517          	auipc	a0,0x4
ffffffffc0201772:	0ea50513          	addi	a0,a0,234 # ffffffffc0205858 <commands+0x868>
ffffffffc0201776:	a61fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_insert(boot_pgdir, p2, PGSIZE, PTE_U | PTE_W) == 0);
ffffffffc020177a:	00004697          	auipc	a3,0x4
ffffffffc020177e:	36668693          	addi	a3,a3,870 # ffffffffc0205ae0 <commands+0xaf0>
ffffffffc0201782:	00004617          	auipc	a2,0x4
ffffffffc0201786:	20660613          	addi	a2,a2,518 # ffffffffc0205988 <commands+0x998>
ffffffffc020178a:	17200593          	li	a1,370
ffffffffc020178e:	00004517          	auipc	a0,0x4
ffffffffc0201792:	0ca50513          	addi	a0,a0,202 # ffffffffc0205858 <commands+0x868>
ffffffffc0201796:	a41fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(get_pte(boot_pgdir, PGSIZE, 0) == ptep);
ffffffffc020179a:	00004697          	auipc	a3,0x4
ffffffffc020179e:	31e68693          	addi	a3,a3,798 # ffffffffc0205ab8 <commands+0xac8>
ffffffffc02017a2:	00004617          	auipc	a2,0x4
ffffffffc02017a6:	1e660613          	addi	a2,a2,486 # ffffffffc0205988 <commands+0x998>
ffffffffc02017aa:	16f00593          	li	a1,367
ffffffffc02017ae:	00004517          	auipc	a0,0x4
ffffffffc02017b2:	0aa50513          	addi	a0,a0,170 # ffffffffc0205858 <commands+0x868>
ffffffffc02017b6:	a21fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    ptep = (pte_t *)KADDR(PDE_ADDR(ptep[0])) + 1;
ffffffffc02017ba:	86da                	mv	a3,s6
ffffffffc02017bc:	00004617          	auipc	a2,0x4
ffffffffc02017c0:	07460613          	addi	a2,a2,116 # ffffffffc0205830 <commands+0x840>
ffffffffc02017c4:	16e00593          	li	a1,366
ffffffffc02017c8:	00004517          	auipc	a0,0x4
ffffffffc02017cc:	09050513          	addi	a0,a0,144 # ffffffffc0205858 <commands+0x868>
ffffffffc02017d0:	a07fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    return KADDR(page2pa(page));
ffffffffc02017d4:	86be                	mv	a3,a5
ffffffffc02017d6:	00004617          	auipc	a2,0x4
ffffffffc02017da:	05a60613          	addi	a2,a2,90 # ffffffffc0205830 <commands+0x840>
ffffffffc02017de:	06900593          	li	a1,105
ffffffffc02017e2:	00004517          	auipc	a0,0x4
ffffffffc02017e6:	0a650513          	addi	a0,a0,166 # ffffffffc0205888 <commands+0x898>
ffffffffc02017ea:	9edfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(pde2page(boot_pgdir[0])) == 1);
ffffffffc02017ee:	00004697          	auipc	a3,0x4
ffffffffc02017f2:	43a68693          	addi	a3,a3,1082 # ffffffffc0205c28 <commands+0xc38>
ffffffffc02017f6:	00004617          	auipc	a2,0x4
ffffffffc02017fa:	19260613          	addi	a2,a2,402 # ffffffffc0205988 <commands+0x998>
ffffffffc02017fe:	18800593          	li	a1,392
ffffffffc0201802:	00004517          	auipc	a0,0x4
ffffffffc0201806:	05650513          	addi	a0,a0,86 # ffffffffc0205858 <commands+0x868>
ffffffffc020180a:	9cdfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p2) == 0);
ffffffffc020180e:	00004697          	auipc	a3,0x4
ffffffffc0201812:	3d268693          	addi	a3,a3,978 # ffffffffc0205be0 <commands+0xbf0>
ffffffffc0201816:	00004617          	auipc	a2,0x4
ffffffffc020181a:	17260613          	addi	a2,a2,370 # ffffffffc0205988 <commands+0x998>
ffffffffc020181e:	18600593          	li	a1,390
ffffffffc0201822:	00004517          	auipc	a0,0x4
ffffffffc0201826:	03650513          	addi	a0,a0,54 # ffffffffc0205858 <commands+0x868>
ffffffffc020182a:	9adfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p1) == 0);
ffffffffc020182e:	00004697          	auipc	a3,0x4
ffffffffc0201832:	3e268693          	addi	a3,a3,994 # ffffffffc0205c10 <commands+0xc20>
ffffffffc0201836:	00004617          	auipc	a2,0x4
ffffffffc020183a:	15260613          	addi	a2,a2,338 # ffffffffc0205988 <commands+0x998>
ffffffffc020183e:	18500593          	li	a1,389
ffffffffc0201842:	00004517          	auipc	a0,0x4
ffffffffc0201846:	01650513          	addi	a0,a0,22 # ffffffffc0205858 <commands+0x868>
ffffffffc020184a:	98dfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p) == 2);
ffffffffc020184e:	00004697          	auipc	a3,0x4
ffffffffc0201852:	54268693          	addi	a3,a3,1346 # ffffffffc0205d90 <commands+0xda0>
ffffffffc0201856:	00004617          	auipc	a2,0x4
ffffffffc020185a:	13260613          	addi	a2,a2,306 # ffffffffc0205988 <commands+0x998>
ffffffffc020185e:	1a800593          	li	a1,424
ffffffffc0201862:	00004517          	auipc	a0,0x4
ffffffffc0201866:	ff650513          	addi	a0,a0,-10 # ffffffffc0205858 <commands+0x868>
ffffffffc020186a:	96dfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_insert(boot_pgdir, p, 0x100 + PGSIZE, PTE_W | PTE_R) == 0);
ffffffffc020186e:	00004697          	auipc	a3,0x4
ffffffffc0201872:	4e268693          	addi	a3,a3,1250 # ffffffffc0205d50 <commands+0xd60>
ffffffffc0201876:	00004617          	auipc	a2,0x4
ffffffffc020187a:	11260613          	addi	a2,a2,274 # ffffffffc0205988 <commands+0x998>
ffffffffc020187e:	1a700593          	li	a1,423
ffffffffc0201882:	00004517          	auipc	a0,0x4
ffffffffc0201886:	fd650513          	addi	a0,a0,-42 # ffffffffc0205858 <commands+0x868>
ffffffffc020188a:	94dfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p) == 1);
ffffffffc020188e:	00004697          	auipc	a3,0x4
ffffffffc0201892:	4aa68693          	addi	a3,a3,1194 # ffffffffc0205d38 <commands+0xd48>
ffffffffc0201896:	00004617          	auipc	a2,0x4
ffffffffc020189a:	0f260613          	addi	a2,a2,242 # ffffffffc0205988 <commands+0x998>
ffffffffc020189e:	1a600593          	li	a1,422
ffffffffc02018a2:	00004517          	auipc	a0,0x4
ffffffffc02018a6:	fb650513          	addi	a0,a0,-74 # ffffffffc0205858 <commands+0x868>
ffffffffc02018aa:	92dfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    ptep = (pte_t *)KADDR(PDE_ADDR(boot_pgdir[0]));
ffffffffc02018ae:	86be                	mv	a3,a5
ffffffffc02018b0:	00004617          	auipc	a2,0x4
ffffffffc02018b4:	f8060613          	addi	a2,a2,-128 # ffffffffc0205830 <commands+0x840>
ffffffffc02018b8:	16d00593          	li	a1,365
ffffffffc02018bc:	00004517          	auipc	a0,0x4
ffffffffc02018c0:	f9c50513          	addi	a0,a0,-100 # ffffffffc0205858 <commands+0x868>
ffffffffc02018c4:	913fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * (npage - nbase));
ffffffffc02018c8:	00004617          	auipc	a2,0x4
ffffffffc02018cc:	04060613          	addi	a2,a2,64 # ffffffffc0205908 <commands+0x918>
ffffffffc02018d0:	07f00593          	li	a1,127
ffffffffc02018d4:	00004517          	auipc	a0,0x4
ffffffffc02018d8:	f8450513          	addi	a0,a0,-124 # ffffffffc0205858 <commands+0x868>
ffffffffc02018dc:	8fbfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(strcmp((void *)0x100, (void *)(0x100 + PGSIZE)) == 0);
ffffffffc02018e0:	00004697          	auipc	a3,0x4
ffffffffc02018e4:	4e068693          	addi	a3,a3,1248 # ffffffffc0205dc0 <commands+0xdd0>
ffffffffc02018e8:	00004617          	auipc	a2,0x4
ffffffffc02018ec:	0a060613          	addi	a2,a2,160 # ffffffffc0205988 <commands+0x998>
ffffffffc02018f0:	1ac00593          	li	a1,428
ffffffffc02018f4:	00004517          	auipc	a0,0x4
ffffffffc02018f8:	f6450513          	addi	a0,a0,-156 # ffffffffc0205858 <commands+0x868>
ffffffffc02018fc:	8dbfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(nr_free_store==nr_free_pages());
ffffffffc0201900:	00004697          	auipc	a3,0x4
ffffffffc0201904:	35068693          	addi	a3,a3,848 # ffffffffc0205c50 <commands+0xc60>
ffffffffc0201908:	00004617          	auipc	a2,0x4
ffffffffc020190c:	08060613          	addi	a2,a2,128 # ffffffffc0205988 <commands+0x998>
ffffffffc0201910:	1b800593          	li	a1,440
ffffffffc0201914:	00004517          	auipc	a0,0x4
ffffffffc0201918:	f4450513          	addi	a0,a0,-188 # ffffffffc0205858 <commands+0x868>
ffffffffc020191c:	8bbfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p1) == 1);
ffffffffc0201920:	00004697          	auipc	a3,0x4
ffffffffc0201924:	18068693          	addi	a3,a3,384 # ffffffffc0205aa0 <commands+0xab0>
ffffffffc0201928:	00004617          	auipc	a2,0x4
ffffffffc020192c:	06060613          	addi	a2,a2,96 # ffffffffc0205988 <commands+0x998>
ffffffffc0201930:	16b00593          	li	a1,363
ffffffffc0201934:	00004517          	auipc	a0,0x4
ffffffffc0201938:	f2450513          	addi	a0,a0,-220 # ffffffffc0205858 <commands+0x868>
ffffffffc020193c:	89bfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pte2page(*ptep) == p1);
ffffffffc0201940:	00004697          	auipc	a3,0x4
ffffffffc0201944:	14868693          	addi	a3,a3,328 # ffffffffc0205a88 <commands+0xa98>
ffffffffc0201948:	00004617          	auipc	a2,0x4
ffffffffc020194c:	04060613          	addi	a2,a2,64 # ffffffffc0205988 <commands+0x998>
ffffffffc0201950:	16a00593          	li	a1,362
ffffffffc0201954:	00004517          	auipc	a0,0x4
ffffffffc0201958:	f0450513          	addi	a0,a0,-252 # ffffffffc0205858 <commands+0x868>
ffffffffc020195c:	87bfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(get_page(boot_pgdir, 0x0, NULL) == NULL);
ffffffffc0201960:	00004697          	auipc	a3,0x4
ffffffffc0201964:	07868693          	addi	a3,a3,120 # ffffffffc02059d8 <commands+0x9e8>
ffffffffc0201968:	00004617          	auipc	a2,0x4
ffffffffc020196c:	02060613          	addi	a2,a2,32 # ffffffffc0205988 <commands+0x998>
ffffffffc0201970:	16200593          	li	a1,354
ffffffffc0201974:	00004517          	auipc	a0,0x4
ffffffffc0201978:	ee450513          	addi	a0,a0,-284 # ffffffffc0205858 <commands+0x868>
ffffffffc020197c:	85bfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL);
ffffffffc0201980:	00004697          	auipc	a3,0x4
ffffffffc0201984:	0b068693          	addi	a3,a3,176 # ffffffffc0205a30 <commands+0xa40>
ffffffffc0201988:	00004617          	auipc	a2,0x4
ffffffffc020198c:	00060613          	mv	a2,a2
ffffffffc0201990:	16900593          	li	a1,361
ffffffffc0201994:	00004517          	auipc	a0,0x4
ffffffffc0201998:	ec450513          	addi	a0,a0,-316 # ffffffffc0205858 <commands+0x868>
ffffffffc020199c:	83bfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_insert(boot_pgdir, p1, 0x0, 0) == 0);
ffffffffc02019a0:	00004697          	auipc	a3,0x4
ffffffffc02019a4:	06068693          	addi	a3,a3,96 # ffffffffc0205a00 <commands+0xa10>
ffffffffc02019a8:	00004617          	auipc	a2,0x4
ffffffffc02019ac:	fe060613          	addi	a2,a2,-32 # ffffffffc0205988 <commands+0x998>
ffffffffc02019b0:	16600593          	li	a1,358
ffffffffc02019b4:	00004517          	auipc	a0,0x4
ffffffffc02019b8:	ea450513          	addi	a0,a0,-348 # ffffffffc0205858 <commands+0x868>
ffffffffc02019bc:	81bfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p2) == 0);
ffffffffc02019c0:	00004697          	auipc	a3,0x4
ffffffffc02019c4:	22068693          	addi	a3,a3,544 # ffffffffc0205be0 <commands+0xbf0>
ffffffffc02019c8:	00004617          	auipc	a2,0x4
ffffffffc02019cc:	fc060613          	addi	a2,a2,-64 # ffffffffc0205988 <commands+0x998>
ffffffffc02019d0:	18200593          	li	a1,386
ffffffffc02019d4:	00004517          	auipc	a0,0x4
ffffffffc02019d8:	e8450513          	addi	a0,a0,-380 # ffffffffc0205858 <commands+0x868>
ffffffffc02019dc:	ffafe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p1) == 1);
ffffffffc02019e0:	00004697          	auipc	a3,0x4
ffffffffc02019e4:	0c068693          	addi	a3,a3,192 # ffffffffc0205aa0 <commands+0xab0>
ffffffffc02019e8:	00004617          	auipc	a2,0x4
ffffffffc02019ec:	fa060613          	addi	a2,a2,-96 # ffffffffc0205988 <commands+0x998>
ffffffffc02019f0:	18100593          	li	a1,385
ffffffffc02019f4:	00004517          	auipc	a0,0x4
ffffffffc02019f8:	e6450513          	addi	a0,a0,-412 # ffffffffc0205858 <commands+0x868>
ffffffffc02019fc:	fdafe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((*ptep & PTE_U) == 0);
ffffffffc0201a00:	00004697          	auipc	a3,0x4
ffffffffc0201a04:	1f868693          	addi	a3,a3,504 # ffffffffc0205bf8 <commands+0xc08>
ffffffffc0201a08:	00004617          	auipc	a2,0x4
ffffffffc0201a0c:	f8060613          	addi	a2,a2,-128 # ffffffffc0205988 <commands+0x998>
ffffffffc0201a10:	17e00593          	li	a1,382
ffffffffc0201a14:	00004517          	auipc	a0,0x4
ffffffffc0201a18:	e4450513          	addi	a0,a0,-444 # ffffffffc0205858 <commands+0x868>
ffffffffc0201a1c:	fbafe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(strlen((const char *)0x100) == 0);
ffffffffc0201a20:	00004697          	auipc	a3,0x4
ffffffffc0201a24:	3d868693          	addi	a3,a3,984 # ffffffffc0205df8 <commands+0xe08>
ffffffffc0201a28:	00004617          	auipc	a2,0x4
ffffffffc0201a2c:	f6060613          	addi	a2,a2,-160 # ffffffffc0205988 <commands+0x998>
ffffffffc0201a30:	1af00593          	li	a1,431
ffffffffc0201a34:	00004517          	auipc	a0,0x4
ffffffffc0201a38:	e2450513          	addi	a0,a0,-476 # ffffffffc0205858 <commands+0x868>
ffffffffc0201a3c:	f9afe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(nr_free_store==nr_free_pages());
ffffffffc0201a40:	00004697          	auipc	a3,0x4
ffffffffc0201a44:	21068693          	addi	a3,a3,528 # ffffffffc0205c50 <commands+0xc60>
ffffffffc0201a48:	00004617          	auipc	a2,0x4
ffffffffc0201a4c:	f4060613          	addi	a2,a2,-192 # ffffffffc0205988 <commands+0x998>
ffffffffc0201a50:	19000593          	li	a1,400
ffffffffc0201a54:	00004517          	auipc	a0,0x4
ffffffffc0201a58:	e0450513          	addi	a0,a0,-508 # ffffffffc0205858 <commands+0x868>
ffffffffc0201a5c:	f7afe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(boot_pgdir[0] == 0);
ffffffffc0201a60:	00004697          	auipc	a3,0x4
ffffffffc0201a64:	28868693          	addi	a3,a3,648 # ffffffffc0205ce8 <commands+0xcf8>
ffffffffc0201a68:	00004617          	auipc	a2,0x4
ffffffffc0201a6c:	f2060613          	addi	a2,a2,-224 # ffffffffc0205988 <commands+0x998>
ffffffffc0201a70:	1a100593          	li	a1,417
ffffffffc0201a74:	00004517          	auipc	a0,0x4
ffffffffc0201a78:	de450513          	addi	a0,a0,-540 # ffffffffc0205858 <commands+0x868>
ffffffffc0201a7c:	f5afe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(npage <= KERNTOP / PGSIZE);
ffffffffc0201a80:	00004697          	auipc	a3,0x4
ffffffffc0201a84:	ee868693          	addi	a3,a3,-280 # ffffffffc0205968 <commands+0x978>
ffffffffc0201a88:	00004617          	auipc	a2,0x4
ffffffffc0201a8c:	f0060613          	addi	a2,a2,-256 # ffffffffc0205988 <commands+0x998>
ffffffffc0201a90:	16000593          	li	a1,352
ffffffffc0201a94:	00004517          	auipc	a0,0x4
ffffffffc0201a98:	dc450513          	addi	a0,a0,-572 # ffffffffc0205858 <commands+0x868>
ffffffffc0201a9c:	f3afe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    boot_cr3 = PADDR(boot_pgdir);
ffffffffc0201aa0:	00004617          	auipc	a2,0x4
ffffffffc0201aa4:	e6860613          	addi	a2,a2,-408 # ffffffffc0205908 <commands+0x918>
ffffffffc0201aa8:	0c300593          	li	a1,195
ffffffffc0201aac:	00004517          	auipc	a0,0x4
ffffffffc0201ab0:	dac50513          	addi	a0,a0,-596 # ffffffffc0205858 <commands+0x868>
ffffffffc0201ab4:	f22fe0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0201ab8 <tlb_invalidate>:
    asm volatile("sfence.vma %0" : : "r"(la));
ffffffffc0201ab8:	12058073          	sfence.vma	a1
}
ffffffffc0201abc:	8082                	ret

ffffffffc0201abe <pgdir_alloc_page>:
struct Page *pgdir_alloc_page(pde_t *pgdir, uintptr_t la, uint32_t perm) {
ffffffffc0201abe:	7179                	addi	sp,sp,-48
ffffffffc0201ac0:	e84a                	sd	s2,16(sp)
ffffffffc0201ac2:	892a                	mv	s2,a0
    struct Page *page = alloc_page();
ffffffffc0201ac4:	4505                	li	a0,1
struct Page *pgdir_alloc_page(pde_t *pgdir, uintptr_t la, uint32_t perm) {
ffffffffc0201ac6:	f022                	sd	s0,32(sp)
ffffffffc0201ac8:	ec26                	sd	s1,24(sp)
ffffffffc0201aca:	e44e                	sd	s3,8(sp)
ffffffffc0201acc:	f406                	sd	ra,40(sp)
ffffffffc0201ace:	84ae                	mv	s1,a1
ffffffffc0201ad0:	89b2                	mv	s3,a2
    struct Page *page = alloc_page();
ffffffffc0201ad2:	8e8ff0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0201ad6:	842a                	mv	s0,a0
    if (page != NULL) {
ffffffffc0201ad8:	cd19                	beqz	a0,ffffffffc0201af6 <pgdir_alloc_page+0x38>
        if (page_insert(pgdir, page, la, perm) != 0) {
ffffffffc0201ada:	85aa                	mv	a1,a0
ffffffffc0201adc:	86ce                	mv	a3,s3
ffffffffc0201ade:	8626                	mv	a2,s1
ffffffffc0201ae0:	854a                	mv	a0,s2
ffffffffc0201ae2:	c8eff0ef          	jal	ra,ffffffffc0200f70 <page_insert>
ffffffffc0201ae6:	ed39                	bnez	a0,ffffffffc0201b44 <pgdir_alloc_page+0x86>
        if (swap_init_ok) {
ffffffffc0201ae8:	00014797          	auipc	a5,0x14
ffffffffc0201aec:	9b878793          	addi	a5,a5,-1608 # ffffffffc02154a0 <swap_init_ok>
ffffffffc0201af0:	439c                	lw	a5,0(a5)
ffffffffc0201af2:	2781                	sext.w	a5,a5
ffffffffc0201af4:	eb89                	bnez	a5,ffffffffc0201b06 <pgdir_alloc_page+0x48>
}
ffffffffc0201af6:	8522                	mv	a0,s0
ffffffffc0201af8:	70a2                	ld	ra,40(sp)
ffffffffc0201afa:	7402                	ld	s0,32(sp)
ffffffffc0201afc:	64e2                	ld	s1,24(sp)
ffffffffc0201afe:	6942                	ld	s2,16(sp)
ffffffffc0201b00:	69a2                	ld	s3,8(sp)
ffffffffc0201b02:	6145                	addi	sp,sp,48
ffffffffc0201b04:	8082                	ret
            swap_map_swappable(check_mm_struct, la, page, 0);
ffffffffc0201b06:	00014797          	auipc	a5,0x14
ffffffffc0201b0a:	9f278793          	addi	a5,a5,-1550 # ffffffffc02154f8 <check_mm_struct>
ffffffffc0201b0e:	6388                	ld	a0,0(a5)
ffffffffc0201b10:	4681                	li	a3,0
ffffffffc0201b12:	8622                	mv	a2,s0
ffffffffc0201b14:	85a6                	mv	a1,s1
ffffffffc0201b16:	7e5000ef          	jal	ra,ffffffffc0202afa <swap_map_swappable>
            assert(page_ref(page) == 1);
ffffffffc0201b1a:	4018                	lw	a4,0(s0)
            page->pra_vaddr = la;
ffffffffc0201b1c:	fc04                	sd	s1,56(s0)
            assert(page_ref(page) == 1);
ffffffffc0201b1e:	4785                	li	a5,1
ffffffffc0201b20:	fcf70be3          	beq	a4,a5,ffffffffc0201af6 <pgdir_alloc_page+0x38>
ffffffffc0201b24:	00004697          	auipc	a3,0x4
ffffffffc0201b28:	d7468693          	addi	a3,a3,-652 # ffffffffc0205898 <commands+0x8a8>
ffffffffc0201b2c:	00004617          	auipc	a2,0x4
ffffffffc0201b30:	e5c60613          	addi	a2,a2,-420 # ffffffffc0205988 <commands+0x998>
ffffffffc0201b34:	14800593          	li	a1,328
ffffffffc0201b38:	00004517          	auipc	a0,0x4
ffffffffc0201b3c:	d2050513          	addi	a0,a0,-736 # ffffffffc0205858 <commands+0x868>
ffffffffc0201b40:	e96fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
            free_page(page);
ffffffffc0201b44:	8522                	mv	a0,s0
ffffffffc0201b46:	4585                	li	a1,1
ffffffffc0201b48:	8faff0ef          	jal	ra,ffffffffc0200c42 <free_pages>
            return NULL;
ffffffffc0201b4c:	4401                	li	s0,0
ffffffffc0201b4e:	b765                	j	ffffffffc0201af6 <pgdir_alloc_page+0x38>

ffffffffc0201b50 <check_vma_overlap.isra.0.part.1>:
}


// check_vma_overlap - check if vma1 overlaps vma2 ?
static inline void
check_vma_overlap(struct vma_struct *prev, struct vma_struct *next) {
ffffffffc0201b50:	1141                	addi	sp,sp,-16
    assert(prev->vm_start < prev->vm_end);
    assert(prev->vm_end <= next->vm_start);
    assert(next->vm_start < next->vm_end);
ffffffffc0201b52:	00004697          	auipc	a3,0x4
ffffffffc0201b56:	2ee68693          	addi	a3,a3,750 # ffffffffc0205e40 <commands+0xe50>
ffffffffc0201b5a:	00004617          	auipc	a2,0x4
ffffffffc0201b5e:	e2e60613          	addi	a2,a2,-466 # ffffffffc0205988 <commands+0x998>
ffffffffc0201b62:	07e00593          	li	a1,126
ffffffffc0201b66:	00004517          	auipc	a0,0x4
ffffffffc0201b6a:	2fa50513          	addi	a0,a0,762 # ffffffffc0205e60 <commands+0xe70>
check_vma_overlap(struct vma_struct *prev, struct vma_struct *next) {
ffffffffc0201b6e:	e406                	sd	ra,8(sp)
    assert(next->vm_start < next->vm_end);
ffffffffc0201b70:	e66fe0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0201b74 <mm_create>:
mm_create(void) {
ffffffffc0201b74:	1141                	addi	sp,sp,-16
    struct mm_struct *mm = kmalloc(sizeof(struct mm_struct));
ffffffffc0201b76:	03000513          	li	a0,48
mm_create(void) {
ffffffffc0201b7a:	e022                	sd	s0,0(sp)
ffffffffc0201b7c:	e406                	sd	ra,8(sp)
    struct mm_struct *mm = kmalloc(sizeof(struct mm_struct));
ffffffffc0201b7e:	3c8010ef          	jal	ra,ffffffffc0202f46 <kmalloc>
ffffffffc0201b82:	842a                	mv	s0,a0
    if (mm != NULL) {
ffffffffc0201b84:	c115                	beqz	a0,ffffffffc0201ba8 <mm_create+0x34>
        if (swap_init_ok) swap_init_mm(mm);
ffffffffc0201b86:	00014797          	auipc	a5,0x14
ffffffffc0201b8a:	91a78793          	addi	a5,a5,-1766 # ffffffffc02154a0 <swap_init_ok>
ffffffffc0201b8e:	439c                	lw	a5,0(a5)
 * list_init - initialize a new entry
 * @elm:        new entry to be initialized
 * */
static inline void
list_init(list_entry_t *elm) {
    elm->prev = elm->next = elm;
ffffffffc0201b90:	e408                	sd	a0,8(s0)
ffffffffc0201b92:	e008                	sd	a0,0(s0)
        mm->mmap_cache = NULL;
ffffffffc0201b94:	00053823          	sd	zero,16(a0)
        mm->pgdir = NULL;
ffffffffc0201b98:	00053c23          	sd	zero,24(a0)
        mm->map_count = 0;
ffffffffc0201b9c:	02052023          	sw	zero,32(a0)
        if (swap_init_ok) swap_init_mm(mm);
ffffffffc0201ba0:	2781                	sext.w	a5,a5
ffffffffc0201ba2:	eb81                	bnez	a5,ffffffffc0201bb2 <mm_create+0x3e>
        else mm->sm_priv = NULL;
ffffffffc0201ba4:	02053423          	sd	zero,40(a0)
}
ffffffffc0201ba8:	8522                	mv	a0,s0
ffffffffc0201baa:	60a2                	ld	ra,8(sp)
ffffffffc0201bac:	6402                	ld	s0,0(sp)
ffffffffc0201bae:	0141                	addi	sp,sp,16
ffffffffc0201bb0:	8082                	ret
        if (swap_init_ok) swap_init_mm(mm);
ffffffffc0201bb2:	739000ef          	jal	ra,ffffffffc0202aea <swap_init_mm>
}
ffffffffc0201bb6:	8522                	mv	a0,s0
ffffffffc0201bb8:	60a2                	ld	ra,8(sp)
ffffffffc0201bba:	6402                	ld	s0,0(sp)
ffffffffc0201bbc:	0141                	addi	sp,sp,16
ffffffffc0201bbe:	8082                	ret

ffffffffc0201bc0 <vma_create>:
vma_create(uintptr_t vm_start, uintptr_t vm_end, uint32_t vm_flags) {
ffffffffc0201bc0:	1101                	addi	sp,sp,-32
ffffffffc0201bc2:	e04a                	sd	s2,0(sp)
ffffffffc0201bc4:	892a                	mv	s2,a0
    struct vma_struct *vma = kmalloc(sizeof(struct vma_struct));
ffffffffc0201bc6:	03000513          	li	a0,48
vma_create(uintptr_t vm_start, uintptr_t vm_end, uint32_t vm_flags) {
ffffffffc0201bca:	e822                	sd	s0,16(sp)
ffffffffc0201bcc:	e426                	sd	s1,8(sp)
ffffffffc0201bce:	ec06                	sd	ra,24(sp)
ffffffffc0201bd0:	84ae                	mv	s1,a1
ffffffffc0201bd2:	8432                	mv	s0,a2
    struct vma_struct *vma = kmalloc(sizeof(struct vma_struct));
ffffffffc0201bd4:	372010ef          	jal	ra,ffffffffc0202f46 <kmalloc>
    if (vma != NULL) {
ffffffffc0201bd8:	c509                	beqz	a0,ffffffffc0201be2 <vma_create+0x22>
        vma->vm_start = vm_start;
ffffffffc0201bda:	01253423          	sd	s2,8(a0)
        vma->vm_end = vm_end;
ffffffffc0201bde:	e904                	sd	s1,16(a0)
        vma->vm_flags = vm_flags;
ffffffffc0201be0:	cd00                	sw	s0,24(a0)
}
ffffffffc0201be2:	60e2                	ld	ra,24(sp)
ffffffffc0201be4:	6442                	ld	s0,16(sp)
ffffffffc0201be6:	64a2                	ld	s1,8(sp)
ffffffffc0201be8:	6902                	ld	s2,0(sp)
ffffffffc0201bea:	6105                	addi	sp,sp,32
ffffffffc0201bec:	8082                	ret

ffffffffc0201bee <find_vma>:
    if (mm != NULL) {
ffffffffc0201bee:	c51d                	beqz	a0,ffffffffc0201c1c <find_vma+0x2e>
        vma = mm->mmap_cache;
ffffffffc0201bf0:	691c                	ld	a5,16(a0)
        if (!(vma != NULL && vma->vm_start <= addr && vma->vm_end > addr)) {
ffffffffc0201bf2:	c781                	beqz	a5,ffffffffc0201bfa <find_vma+0xc>
ffffffffc0201bf4:	6798                	ld	a4,8(a5)
ffffffffc0201bf6:	02e5f663          	bleu	a4,a1,ffffffffc0201c22 <find_vma+0x34>
                list_entry_t *list = &(mm->mmap_list), *le = list;
ffffffffc0201bfa:	87aa                	mv	a5,a0
 * list_next - get the next entry
 * @listelm:    the list head
 **/
static inline list_entry_t *
list_next(list_entry_t *listelm) {
    return listelm->next;
ffffffffc0201bfc:	679c                	ld	a5,8(a5)
                while ((le = list_next(le)) != list) {
ffffffffc0201bfe:	00f50f63          	beq	a0,a5,ffffffffc0201c1c <find_vma+0x2e>
                    if (vma->vm_start<=addr && addr < vma->vm_end) {
ffffffffc0201c02:	fe87b703          	ld	a4,-24(a5)
ffffffffc0201c06:	fee5ebe3          	bltu	a1,a4,ffffffffc0201bfc <find_vma+0xe>
ffffffffc0201c0a:	ff07b703          	ld	a4,-16(a5)
ffffffffc0201c0e:	fee5f7e3          	bleu	a4,a1,ffffffffc0201bfc <find_vma+0xe>
                    vma = le2vma(le, list_link);
ffffffffc0201c12:	1781                	addi	a5,a5,-32
        if (vma != NULL) {
ffffffffc0201c14:	c781                	beqz	a5,ffffffffc0201c1c <find_vma+0x2e>
            mm->mmap_cache = vma;
ffffffffc0201c16:	e91c                	sd	a5,16(a0)
}
ffffffffc0201c18:	853e                	mv	a0,a5
ffffffffc0201c1a:	8082                	ret
    struct vma_struct *vma = NULL;
ffffffffc0201c1c:	4781                	li	a5,0
}
ffffffffc0201c1e:	853e                	mv	a0,a5
ffffffffc0201c20:	8082                	ret
        if (!(vma != NULL && vma->vm_start <= addr && vma->vm_end > addr)) {
ffffffffc0201c22:	6b98                	ld	a4,16(a5)
ffffffffc0201c24:	fce5fbe3          	bleu	a4,a1,ffffffffc0201bfa <find_vma+0xc>
            mm->mmap_cache = vma;
ffffffffc0201c28:	e91c                	sd	a5,16(a0)
    return vma;
ffffffffc0201c2a:	b7fd                	j	ffffffffc0201c18 <find_vma+0x2a>

ffffffffc0201c2c <insert_vma_struct>:


// insert_vma_struct -insert vma in mm's list link
void
insert_vma_struct(struct mm_struct *mm, struct vma_struct *vma) {
    assert(vma->vm_start < vma->vm_end);
ffffffffc0201c2c:	6590                	ld	a2,8(a1)
ffffffffc0201c2e:	0105b803          	ld	a6,16(a1)
insert_vma_struct(struct mm_struct *mm, struct vma_struct *vma) {
ffffffffc0201c32:	1141                	addi	sp,sp,-16
ffffffffc0201c34:	e406                	sd	ra,8(sp)
ffffffffc0201c36:	872a                	mv	a4,a0
    assert(vma->vm_start < vma->vm_end);
ffffffffc0201c38:	01066863          	bltu	a2,a6,ffffffffc0201c48 <insert_vma_struct+0x1c>
ffffffffc0201c3c:	a8b9                	j	ffffffffc0201c9a <insert_vma_struct+0x6e>
    list_entry_t *le_prev = list, *le_next;

        list_entry_t *le = list;
        while ((le = list_next(le)) != list) {
            struct vma_struct *mmap_prev = le2vma(le, list_link);
            if (mmap_prev->vm_start > vma->vm_start) {
ffffffffc0201c3e:	fe87b683          	ld	a3,-24(a5)
ffffffffc0201c42:	04d66763          	bltu	a2,a3,ffffffffc0201c90 <insert_vma_struct+0x64>
ffffffffc0201c46:	873e                	mv	a4,a5
ffffffffc0201c48:	671c                	ld	a5,8(a4)
        while ((le = list_next(le)) != list) {
ffffffffc0201c4a:	fef51ae3          	bne	a0,a5,ffffffffc0201c3e <insert_vma_struct+0x12>
        }

    le_next = list_next(le_prev);

    /* check overlap */
    if (le_prev != list) {
ffffffffc0201c4e:	02a70463          	beq	a4,a0,ffffffffc0201c76 <insert_vma_struct+0x4a>
        check_vma_overlap(le2vma(le_prev, list_link), vma);
ffffffffc0201c52:	ff073683          	ld	a3,-16(a4) # 7fff0 <BASE_ADDRESS-0xffffffffc0180010>
    assert(prev->vm_start < prev->vm_end);
ffffffffc0201c56:	fe873883          	ld	a7,-24(a4)
ffffffffc0201c5a:	08d8f063          	bleu	a3,a7,ffffffffc0201cda <insert_vma_struct+0xae>
    assert(prev->vm_end <= next->vm_start);
ffffffffc0201c5e:	04d66e63          	bltu	a2,a3,ffffffffc0201cba <insert_vma_struct+0x8e>
    }
    if (le_next != list) {
ffffffffc0201c62:	00f50a63          	beq	a0,a5,ffffffffc0201c76 <insert_vma_struct+0x4a>
ffffffffc0201c66:	fe87b683          	ld	a3,-24(a5)
    assert(prev->vm_end <= next->vm_start);
ffffffffc0201c6a:	0506e863          	bltu	a3,a6,ffffffffc0201cba <insert_vma_struct+0x8e>
    assert(next->vm_start < next->vm_end);
ffffffffc0201c6e:	ff07b603          	ld	a2,-16(a5)
ffffffffc0201c72:	02c6f263          	bleu	a2,a3,ffffffffc0201c96 <insert_vma_struct+0x6a>
    }

    vma->vm_mm = mm;
    list_add_after(le_prev, &(vma->list_link));

    mm->map_count ++;
ffffffffc0201c76:	5114                	lw	a3,32(a0)
    vma->vm_mm = mm;
ffffffffc0201c78:	e188                	sd	a0,0(a1)
    list_add_after(le_prev, &(vma->list_link));
ffffffffc0201c7a:	02058613          	addi	a2,a1,32
 * This is only for internal list manipulation where we know
 * the prev/next entries already!
 * */
static inline void
__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) {
    prev->next = next->prev = elm;
ffffffffc0201c7e:	e390                	sd	a2,0(a5)
ffffffffc0201c80:	e710                	sd	a2,8(a4)
}
ffffffffc0201c82:	60a2                	ld	ra,8(sp)
    elm->next = next;
ffffffffc0201c84:	f59c                	sd	a5,40(a1)
    elm->prev = prev;
ffffffffc0201c86:	f198                	sd	a4,32(a1)
    mm->map_count ++;
ffffffffc0201c88:	2685                	addiw	a3,a3,1
ffffffffc0201c8a:	d114                	sw	a3,32(a0)
}
ffffffffc0201c8c:	0141                	addi	sp,sp,16
ffffffffc0201c8e:	8082                	ret
    if (le_prev != list) {
ffffffffc0201c90:	fca711e3          	bne	a4,a0,ffffffffc0201c52 <insert_vma_struct+0x26>
ffffffffc0201c94:	bfd9                	j	ffffffffc0201c6a <insert_vma_struct+0x3e>
ffffffffc0201c96:	ebbff0ef          	jal	ra,ffffffffc0201b50 <check_vma_overlap.isra.0.part.1>
    assert(vma->vm_start < vma->vm_end);
ffffffffc0201c9a:	00004697          	auipc	a3,0x4
ffffffffc0201c9e:	29668693          	addi	a3,a3,662 # ffffffffc0205f30 <commands+0xf40>
ffffffffc0201ca2:	00004617          	auipc	a2,0x4
ffffffffc0201ca6:	ce660613          	addi	a2,a2,-794 # ffffffffc0205988 <commands+0x998>
ffffffffc0201caa:	08500593          	li	a1,133
ffffffffc0201cae:	00004517          	auipc	a0,0x4
ffffffffc0201cb2:	1b250513          	addi	a0,a0,434 # ffffffffc0205e60 <commands+0xe70>
ffffffffc0201cb6:	d20fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(prev->vm_end <= next->vm_start);
ffffffffc0201cba:	00004697          	auipc	a3,0x4
ffffffffc0201cbe:	2b668693          	addi	a3,a3,694 # ffffffffc0205f70 <commands+0xf80>
ffffffffc0201cc2:	00004617          	auipc	a2,0x4
ffffffffc0201cc6:	cc660613          	addi	a2,a2,-826 # ffffffffc0205988 <commands+0x998>
ffffffffc0201cca:	07d00593          	li	a1,125
ffffffffc0201cce:	00004517          	auipc	a0,0x4
ffffffffc0201cd2:	19250513          	addi	a0,a0,402 # ffffffffc0205e60 <commands+0xe70>
ffffffffc0201cd6:	d00fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(prev->vm_start < prev->vm_end);
ffffffffc0201cda:	00004697          	auipc	a3,0x4
ffffffffc0201cde:	27668693          	addi	a3,a3,630 # ffffffffc0205f50 <commands+0xf60>
ffffffffc0201ce2:	00004617          	auipc	a2,0x4
ffffffffc0201ce6:	ca660613          	addi	a2,a2,-858 # ffffffffc0205988 <commands+0x998>
ffffffffc0201cea:	07c00593          	li	a1,124
ffffffffc0201cee:	00004517          	auipc	a0,0x4
ffffffffc0201cf2:	17250513          	addi	a0,a0,370 # ffffffffc0205e60 <commands+0xe70>
ffffffffc0201cf6:	ce0fe0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0201cfa <mm_destroy>:

// mm_destroy - free mm and mm internal fields
void
mm_destroy(struct mm_struct *mm) {
ffffffffc0201cfa:	1141                	addi	sp,sp,-16
ffffffffc0201cfc:	e022                	sd	s0,0(sp)
ffffffffc0201cfe:	842a                	mv	s0,a0
    return listelm->next;
ffffffffc0201d00:	6508                	ld	a0,8(a0)
ffffffffc0201d02:	e406                	sd	ra,8(sp)

    list_entry_t *list = &(mm->mmap_list), *le;
    while ((le = list_next(list)) != list) {
ffffffffc0201d04:	00a40c63          	beq	s0,a0,ffffffffc0201d1c <mm_destroy+0x22>
    __list_del(listelm->prev, listelm->next);
ffffffffc0201d08:	6118                	ld	a4,0(a0)
ffffffffc0201d0a:	651c                	ld	a5,8(a0)
        list_del(le);
        kfree(le2vma(le, list_link));  //kfree vma        
ffffffffc0201d0c:	1501                	addi	a0,a0,-32
 * This is only for internal list manipulation where we know
 * the prev/next entries already!
 * */
static inline void
__list_del(list_entry_t *prev, list_entry_t *next) {
    prev->next = next;
ffffffffc0201d0e:	e71c                	sd	a5,8(a4)
    next->prev = prev;
ffffffffc0201d10:	e398                	sd	a4,0(a5)
ffffffffc0201d12:	2f0010ef          	jal	ra,ffffffffc0203002 <kfree>
    return listelm->next;
ffffffffc0201d16:	6408                	ld	a0,8(s0)
    while ((le = list_next(list)) != list) {
ffffffffc0201d18:	fea418e3          	bne	s0,a0,ffffffffc0201d08 <mm_destroy+0xe>
    }
    kfree(mm); //kfree mm
ffffffffc0201d1c:	8522                	mv	a0,s0
    mm=NULL;
}
ffffffffc0201d1e:	6402                	ld	s0,0(sp)
ffffffffc0201d20:	60a2                	ld	ra,8(sp)
ffffffffc0201d22:	0141                	addi	sp,sp,16
    kfree(mm); //kfree mm
ffffffffc0201d24:	2de0106f          	j	ffffffffc0203002 <kfree>

ffffffffc0201d28 <vmm_init>:

// vmm_init - initialize virtual memory management
//          - now just call check_vmm to check correctness of vmm
void
vmm_init(void) {
ffffffffc0201d28:	7139                	addi	sp,sp,-64
ffffffffc0201d2a:	f822                	sd	s0,48(sp)
ffffffffc0201d2c:	f426                	sd	s1,40(sp)
ffffffffc0201d2e:	fc06                	sd	ra,56(sp)
ffffffffc0201d30:	f04a                	sd	s2,32(sp)
ffffffffc0201d32:	ec4e                	sd	s3,24(sp)
ffffffffc0201d34:	e852                	sd	s4,16(sp)
ffffffffc0201d36:	e456                	sd	s5,8(sp)
    cprintf("check_vmm() succeeded.\n");
}

static void
check_vma_struct(void) {
    struct mm_struct *mm = mm_create();
ffffffffc0201d38:	e3dff0ef          	jal	ra,ffffffffc0201b74 <mm_create>
    assert(mm != NULL);
ffffffffc0201d3c:	842a                	mv	s0,a0
ffffffffc0201d3e:	03200493          	li	s1,50
ffffffffc0201d42:	e919                	bnez	a0,ffffffffc0201d58 <vmm_init+0x30>
ffffffffc0201d44:	a989                	j	ffffffffc0202196 <vmm_init+0x46e>
        vma->vm_start = vm_start;
ffffffffc0201d46:	e504                	sd	s1,8(a0)
        vma->vm_end = vm_end;
ffffffffc0201d48:	e91c                	sd	a5,16(a0)
        vma->vm_flags = vm_flags;
ffffffffc0201d4a:	00052c23          	sw	zero,24(a0)

    int i;
    for (i = step1; i >= 1; i --) {
        struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
        assert(vma != NULL);
        insert_vma_struct(mm, vma);
ffffffffc0201d4e:	14ed                	addi	s1,s1,-5
ffffffffc0201d50:	8522                	mv	a0,s0
ffffffffc0201d52:	edbff0ef          	jal	ra,ffffffffc0201c2c <insert_vma_struct>
    for (i = step1; i >= 1; i --) {
ffffffffc0201d56:	c88d                	beqz	s1,ffffffffc0201d88 <vmm_init+0x60>
    struct vma_struct *vma = kmalloc(sizeof(struct vma_struct));
ffffffffc0201d58:	03000513          	li	a0,48
ffffffffc0201d5c:	1ea010ef          	jal	ra,ffffffffc0202f46 <kmalloc>
ffffffffc0201d60:	85aa                	mv	a1,a0
ffffffffc0201d62:	00248793          	addi	a5,s1,2
    if (vma != NULL) {
ffffffffc0201d66:	f165                	bnez	a0,ffffffffc0201d46 <vmm_init+0x1e>
        assert(vma != NULL);
ffffffffc0201d68:	00004697          	auipc	a3,0x4
ffffffffc0201d6c:	45068693          	addi	a3,a3,1104 # ffffffffc02061b8 <commands+0x11c8>
ffffffffc0201d70:	00004617          	auipc	a2,0x4
ffffffffc0201d74:	c1860613          	addi	a2,a2,-1000 # ffffffffc0205988 <commands+0x998>
ffffffffc0201d78:	0c900593          	li	a1,201
ffffffffc0201d7c:	00004517          	auipc	a0,0x4
ffffffffc0201d80:	0e450513          	addi	a0,a0,228 # ffffffffc0205e60 <commands+0xe70>
ffffffffc0201d84:	c52fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    for (i = step1; i >= 1; i --) {
ffffffffc0201d88:	03700493          	li	s1,55
    }

    for (i = step1 + 1; i <= step2; i ++) {
ffffffffc0201d8c:	1f900913          	li	s2,505
ffffffffc0201d90:	a819                	j	ffffffffc0201da6 <vmm_init+0x7e>
        vma->vm_start = vm_start;
ffffffffc0201d92:	e504                	sd	s1,8(a0)
        vma->vm_end = vm_end;
ffffffffc0201d94:	e91c                	sd	a5,16(a0)
        vma->vm_flags = vm_flags;
ffffffffc0201d96:	00052c23          	sw	zero,24(a0)
        struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
        assert(vma != NULL);
        insert_vma_struct(mm, vma);
ffffffffc0201d9a:	0495                	addi	s1,s1,5
ffffffffc0201d9c:	8522                	mv	a0,s0
ffffffffc0201d9e:	e8fff0ef          	jal	ra,ffffffffc0201c2c <insert_vma_struct>
    for (i = step1 + 1; i <= step2; i ++) {
ffffffffc0201da2:	03248a63          	beq	s1,s2,ffffffffc0201dd6 <vmm_init+0xae>
    struct vma_struct *vma = kmalloc(sizeof(struct vma_struct));
ffffffffc0201da6:	03000513          	li	a0,48
ffffffffc0201daa:	19c010ef          	jal	ra,ffffffffc0202f46 <kmalloc>
ffffffffc0201dae:	85aa                	mv	a1,a0
ffffffffc0201db0:	00248793          	addi	a5,s1,2
    if (vma != NULL) {
ffffffffc0201db4:	fd79                	bnez	a0,ffffffffc0201d92 <vmm_init+0x6a>
        assert(vma != NULL);
ffffffffc0201db6:	00004697          	auipc	a3,0x4
ffffffffc0201dba:	40268693          	addi	a3,a3,1026 # ffffffffc02061b8 <commands+0x11c8>
ffffffffc0201dbe:	00004617          	auipc	a2,0x4
ffffffffc0201dc2:	bca60613          	addi	a2,a2,-1078 # ffffffffc0205988 <commands+0x998>
ffffffffc0201dc6:	0cf00593          	li	a1,207
ffffffffc0201dca:	00004517          	auipc	a0,0x4
ffffffffc0201dce:	09650513          	addi	a0,a0,150 # ffffffffc0205e60 <commands+0xe70>
ffffffffc0201dd2:	c04fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
ffffffffc0201dd6:	6418                	ld	a4,8(s0)
ffffffffc0201dd8:	479d                	li	a5,7
    }

    list_entry_t *le = list_next(&(mm->mmap_list));

    for (i = 1; i <= step2; i ++) {
ffffffffc0201dda:	1fb00593          	li	a1,507
        assert(le != &(mm->mmap_list));
ffffffffc0201dde:	2ee40063          	beq	s0,a4,ffffffffc02020be <vmm_init+0x396>
        struct vma_struct *mmap = le2vma(le, list_link);
        assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
ffffffffc0201de2:	fe873603          	ld	a2,-24(a4)
ffffffffc0201de6:	ffe78693          	addi	a3,a5,-2
ffffffffc0201dea:	24d61a63          	bne	a2,a3,ffffffffc020203e <vmm_init+0x316>
ffffffffc0201dee:	ff073683          	ld	a3,-16(a4)
ffffffffc0201df2:	24f69663          	bne	a3,a5,ffffffffc020203e <vmm_init+0x316>
ffffffffc0201df6:	0795                	addi	a5,a5,5
ffffffffc0201df8:	6718                	ld	a4,8(a4)
    for (i = 1; i <= step2; i ++) {
ffffffffc0201dfa:	feb792e3          	bne	a5,a1,ffffffffc0201dde <vmm_init+0xb6>
ffffffffc0201dfe:	491d                	li	s2,7
ffffffffc0201e00:	4495                	li	s1,5
        le = list_next(le);
    }

    for (i = 5; i <= 5 * step2; i +=5) {
ffffffffc0201e02:	1f900a93          	li	s5,505
        struct vma_struct *vma1 = find_vma(mm, i);
ffffffffc0201e06:	85a6                	mv	a1,s1
ffffffffc0201e08:	8522                	mv	a0,s0
ffffffffc0201e0a:	de5ff0ef          	jal	ra,ffffffffc0201bee <find_vma>
ffffffffc0201e0e:	8a2a                	mv	s4,a0
        assert(vma1 != NULL);
ffffffffc0201e10:	30050763          	beqz	a0,ffffffffc020211e <vmm_init+0x3f6>
        struct vma_struct *vma2 = find_vma(mm, i+1);
ffffffffc0201e14:	00148593          	addi	a1,s1,1
ffffffffc0201e18:	8522                	mv	a0,s0
ffffffffc0201e1a:	dd5ff0ef          	jal	ra,ffffffffc0201bee <find_vma>
ffffffffc0201e1e:	89aa                	mv	s3,a0
        assert(vma2 != NULL);
ffffffffc0201e20:	2c050f63          	beqz	a0,ffffffffc02020fe <vmm_init+0x3d6>
        struct vma_struct *vma3 = find_vma(mm, i+2);
ffffffffc0201e24:	85ca                	mv	a1,s2
ffffffffc0201e26:	8522                	mv	a0,s0
ffffffffc0201e28:	dc7ff0ef          	jal	ra,ffffffffc0201bee <find_vma>
        assert(vma3 == NULL);
ffffffffc0201e2c:	2a051963          	bnez	a0,ffffffffc02020de <vmm_init+0x3b6>
        struct vma_struct *vma4 = find_vma(mm, i+3);
ffffffffc0201e30:	00348593          	addi	a1,s1,3
ffffffffc0201e34:	8522                	mv	a0,s0
ffffffffc0201e36:	db9ff0ef          	jal	ra,ffffffffc0201bee <find_vma>
        assert(vma4 == NULL);
ffffffffc0201e3a:	32051263          	bnez	a0,ffffffffc020215e <vmm_init+0x436>
        struct vma_struct *vma5 = find_vma(mm, i+4);
ffffffffc0201e3e:	00448593          	addi	a1,s1,4
ffffffffc0201e42:	8522                	mv	a0,s0
ffffffffc0201e44:	dabff0ef          	jal	ra,ffffffffc0201bee <find_vma>
        assert(vma5 == NULL);
ffffffffc0201e48:	2e051b63          	bnez	a0,ffffffffc020213e <vmm_init+0x416>

        assert(vma1->vm_start == i  && vma1->vm_end == i  + 2);
ffffffffc0201e4c:	008a3783          	ld	a5,8(s4)
ffffffffc0201e50:	20979763          	bne	a5,s1,ffffffffc020205e <vmm_init+0x336>
ffffffffc0201e54:	010a3783          	ld	a5,16(s4)
ffffffffc0201e58:	21279363          	bne	a5,s2,ffffffffc020205e <vmm_init+0x336>
        assert(vma2->vm_start == i  && vma2->vm_end == i  + 2);
ffffffffc0201e5c:	0089b783          	ld	a5,8(s3) # fffffffffff80008 <end+0x3fd6aa08>
ffffffffc0201e60:	20979f63          	bne	a5,s1,ffffffffc020207e <vmm_init+0x356>
ffffffffc0201e64:	0109b783          	ld	a5,16(s3)
ffffffffc0201e68:	21279b63          	bne	a5,s2,ffffffffc020207e <vmm_init+0x356>
ffffffffc0201e6c:	0495                	addi	s1,s1,5
ffffffffc0201e6e:	0915                	addi	s2,s2,5
    for (i = 5; i <= 5 * step2; i +=5) {
ffffffffc0201e70:	f9549be3          	bne	s1,s5,ffffffffc0201e06 <vmm_init+0xde>
ffffffffc0201e74:	4491                	li	s1,4
    }

    for (i =4; i>=0; i--) {
ffffffffc0201e76:	597d                	li	s2,-1
        struct vma_struct *vma_below_5= find_vma(mm,i);
ffffffffc0201e78:	85a6                	mv	a1,s1
ffffffffc0201e7a:	8522                	mv	a0,s0
ffffffffc0201e7c:	d73ff0ef          	jal	ra,ffffffffc0201bee <find_vma>
ffffffffc0201e80:	0004859b          	sext.w	a1,s1
        if (vma_below_5 != NULL ) {
ffffffffc0201e84:	c90d                	beqz	a0,ffffffffc0201eb6 <vmm_init+0x18e>
           cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end); 
ffffffffc0201e86:	6914                	ld	a3,16(a0)
ffffffffc0201e88:	6510                	ld	a2,8(a0)
ffffffffc0201e8a:	00004517          	auipc	a0,0x4
ffffffffc0201e8e:	21650513          	addi	a0,a0,534 # ffffffffc02060a0 <commands+0x10b0>
ffffffffc0201e92:	a3efe0ef          	jal	ra,ffffffffc02000d0 <cprintf>
        }
        assert(vma_below_5 == NULL);
ffffffffc0201e96:	00004697          	auipc	a3,0x4
ffffffffc0201e9a:	23268693          	addi	a3,a3,562 # ffffffffc02060c8 <commands+0x10d8>
ffffffffc0201e9e:	00004617          	auipc	a2,0x4
ffffffffc0201ea2:	aea60613          	addi	a2,a2,-1302 # ffffffffc0205988 <commands+0x998>
ffffffffc0201ea6:	0f100593          	li	a1,241
ffffffffc0201eaa:	00004517          	auipc	a0,0x4
ffffffffc0201eae:	fb650513          	addi	a0,a0,-74 # ffffffffc0205e60 <commands+0xe70>
ffffffffc0201eb2:	b24fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
ffffffffc0201eb6:	14fd                	addi	s1,s1,-1
    for (i =4; i>=0; i--) {
ffffffffc0201eb8:	fd2490e3          	bne	s1,s2,ffffffffc0201e78 <vmm_init+0x150>
    }

    mm_destroy(mm);
ffffffffc0201ebc:	8522                	mv	a0,s0
ffffffffc0201ebe:	e3dff0ef          	jal	ra,ffffffffc0201cfa <mm_destroy>

    cprintf("check_vma_struct() succeeded!\n");
ffffffffc0201ec2:	00004517          	auipc	a0,0x4
ffffffffc0201ec6:	21e50513          	addi	a0,a0,542 # ffffffffc02060e0 <commands+0x10f0>
ffffffffc0201eca:	a06fe0ef          	jal	ra,ffffffffc02000d0 <cprintf>
struct mm_struct *check_mm_struct;

// check_pgfault - check correctness of pgfault handler
static void
check_pgfault(void) {
    size_t nr_free_pages_store = nr_free_pages();
ffffffffc0201ece:	dbbfe0ef          	jal	ra,ffffffffc0200c88 <nr_free_pages>
ffffffffc0201ed2:	89aa                	mv	s3,a0

    check_mm_struct = mm_create();
ffffffffc0201ed4:	ca1ff0ef          	jal	ra,ffffffffc0201b74 <mm_create>
ffffffffc0201ed8:	00013797          	auipc	a5,0x13
ffffffffc0201edc:	62a7b023          	sd	a0,1568(a5) # ffffffffc02154f8 <check_mm_struct>
ffffffffc0201ee0:	84aa                	mv	s1,a0
    assert(check_mm_struct != NULL);
ffffffffc0201ee2:	36050663          	beqz	a0,ffffffffc020224e <vmm_init+0x526>

    struct mm_struct *mm = check_mm_struct;
    pde_t *pgdir = mm->pgdir = boot_pgdir;
ffffffffc0201ee6:	00013797          	auipc	a5,0x13
ffffffffc0201eea:	59a78793          	addi	a5,a5,1434 # ffffffffc0215480 <boot_pgdir>
ffffffffc0201eee:	0007b903          	ld	s2,0(a5)
    assert(pgdir[0] == 0);
ffffffffc0201ef2:	00093783          	ld	a5,0(s2)
    pde_t *pgdir = mm->pgdir = boot_pgdir;
ffffffffc0201ef6:	01253c23          	sd	s2,24(a0)
    assert(pgdir[0] == 0);
ffffffffc0201efa:	2c079e63          	bnez	a5,ffffffffc02021d6 <vmm_init+0x4ae>
    struct vma_struct *vma = kmalloc(sizeof(struct vma_struct));
ffffffffc0201efe:	03000513          	li	a0,48
ffffffffc0201f02:	044010ef          	jal	ra,ffffffffc0202f46 <kmalloc>
ffffffffc0201f06:	842a                	mv	s0,a0
    if (vma != NULL) {
ffffffffc0201f08:	18050b63          	beqz	a0,ffffffffc020209e <vmm_init+0x376>
        vma->vm_end = vm_end;
ffffffffc0201f0c:	002007b7          	lui	a5,0x200
ffffffffc0201f10:	e81c                	sd	a5,16(s0)
        vma->vm_flags = vm_flags;
ffffffffc0201f12:	4789                	li	a5,2

    struct vma_struct *vma = vma_create(0, PTSIZE, VM_WRITE);
    assert(vma != NULL);

    insert_vma_struct(mm, vma);
ffffffffc0201f14:	85aa                	mv	a1,a0
        vma->vm_flags = vm_flags;
ffffffffc0201f16:	cc1c                	sw	a5,24(s0)
    insert_vma_struct(mm, vma);
ffffffffc0201f18:	8526                	mv	a0,s1
        vma->vm_start = vm_start;
ffffffffc0201f1a:	00043423          	sd	zero,8(s0)
    insert_vma_struct(mm, vma);
ffffffffc0201f1e:	d0fff0ef          	jal	ra,ffffffffc0201c2c <insert_vma_struct>

    uintptr_t addr = 0x100;
    assert(find_vma(mm, addr) == vma);
ffffffffc0201f22:	10000593          	li	a1,256
ffffffffc0201f26:	8526                	mv	a0,s1
ffffffffc0201f28:	cc7ff0ef          	jal	ra,ffffffffc0201bee <find_vma>
ffffffffc0201f2c:	10000793          	li	a5,256

    int i, sum = 0;
    for (i = 0; i < 100; i ++) {
ffffffffc0201f30:	16400713          	li	a4,356
    assert(find_vma(mm, addr) == vma);
ffffffffc0201f34:	2ca41163          	bne	s0,a0,ffffffffc02021f6 <vmm_init+0x4ce>
        *(char *)(addr + i) = i;
ffffffffc0201f38:	00f78023          	sb	a5,0(a5) # 200000 <BASE_ADDRESS-0xffffffffc0000000>
        sum += i;
ffffffffc0201f3c:	0785                	addi	a5,a5,1
    for (i = 0; i < 100; i ++) {
ffffffffc0201f3e:	fee79de3          	bne	a5,a4,ffffffffc0201f38 <vmm_init+0x210>
        sum += i;
ffffffffc0201f42:	6705                	lui	a4,0x1
    for (i = 0; i < 100; i ++) {
ffffffffc0201f44:	10000793          	li	a5,256
        sum += i;
ffffffffc0201f48:	35670713          	addi	a4,a4,854 # 1356 <BASE_ADDRESS-0xffffffffc01fecaa>
    }
    for (i = 0; i < 100; i ++) {
ffffffffc0201f4c:	16400613          	li	a2,356
        sum -= *(char *)(addr + i);
ffffffffc0201f50:	0007c683          	lbu	a3,0(a5)
ffffffffc0201f54:	0785                	addi	a5,a5,1
ffffffffc0201f56:	9f15                	subw	a4,a4,a3
    for (i = 0; i < 100; i ++) {
ffffffffc0201f58:	fec79ce3          	bne	a5,a2,ffffffffc0201f50 <vmm_init+0x228>
    }
    assert(sum == 0);
ffffffffc0201f5c:	2c071963          	bnez	a4,ffffffffc020222e <vmm_init+0x506>
    return pa2page(PDE_ADDR(pde));
ffffffffc0201f60:	00093783          	ld	a5,0(s2)
    if (PPN(pa) >= npage) {
ffffffffc0201f64:	00013a97          	auipc	s5,0x13
ffffffffc0201f68:	524a8a93          	addi	s5,s5,1316 # ffffffffc0215488 <npage>
ffffffffc0201f6c:	000ab703          	ld	a4,0(s5)
    return pa2page(PDE_ADDR(pde));
ffffffffc0201f70:	078a                	slli	a5,a5,0x2
ffffffffc0201f72:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc0201f74:	20e7f563          	bleu	a4,a5,ffffffffc020217e <vmm_init+0x456>
    return &pages[PPN(pa) - nbase];
ffffffffc0201f78:	00005697          	auipc	a3,0x5
ffffffffc0201f7c:	02868693          	addi	a3,a3,40 # ffffffffc0206fa0 <nbase>
ffffffffc0201f80:	0006ba03          	ld	s4,0(a3)
ffffffffc0201f84:	414786b3          	sub	a3,a5,s4
ffffffffc0201f88:	069a                	slli	a3,a3,0x6
    return page - pages + nbase;
ffffffffc0201f8a:	8699                	srai	a3,a3,0x6
    return KADDR(page2pa(page));
ffffffffc0201f8c:	57fd                	li	a5,-1
    return page - pages + nbase;
ffffffffc0201f8e:	96d2                	add	a3,a3,s4
    return KADDR(page2pa(page));
ffffffffc0201f90:	83b1                	srli	a5,a5,0xc
ffffffffc0201f92:	8ff5                	and	a5,a5,a3
    return page2ppn(page) << PGSHIFT;
ffffffffc0201f94:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc0201f96:	28e7f063          	bleu	a4,a5,ffffffffc0202216 <vmm_init+0x4ee>
ffffffffc0201f9a:	00013797          	auipc	a5,0x13
ffffffffc0201f9e:	54678793          	addi	a5,a5,1350 # ffffffffc02154e0 <va_pa_offset>
ffffffffc0201fa2:	6380                	ld	s0,0(a5)

    pde_t *pd1=pgdir,*pd0=page2kva(pde2page(pgdir[0]));
    page_remove(pgdir, ROUNDDOWN(addr, PGSIZE));
ffffffffc0201fa4:	4581                	li	a1,0
ffffffffc0201fa6:	854a                	mv	a0,s2
ffffffffc0201fa8:	9436                	add	s0,s0,a3
ffffffffc0201faa:	f53fe0ef          	jal	ra,ffffffffc0200efc <page_remove>
    return pa2page(PDE_ADDR(pde));
ffffffffc0201fae:	601c                	ld	a5,0(s0)
    if (PPN(pa) >= npage) {
ffffffffc0201fb0:	000ab703          	ld	a4,0(s5)
    return pa2page(PDE_ADDR(pde));
ffffffffc0201fb4:	078a                	slli	a5,a5,0x2
ffffffffc0201fb6:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc0201fb8:	1ce7f363          	bleu	a4,a5,ffffffffc020217e <vmm_init+0x456>
    return &pages[PPN(pa) - nbase];
ffffffffc0201fbc:	00013417          	auipc	s0,0x13
ffffffffc0201fc0:	53440413          	addi	s0,s0,1332 # ffffffffc02154f0 <pages>
ffffffffc0201fc4:	6008                	ld	a0,0(s0)
ffffffffc0201fc6:	414787b3          	sub	a5,a5,s4
ffffffffc0201fca:	079a                	slli	a5,a5,0x6
    free_page(pde2page(pd0[0]));
ffffffffc0201fcc:	953e                	add	a0,a0,a5
ffffffffc0201fce:	4585                	li	a1,1
ffffffffc0201fd0:	c73fe0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    return pa2page(PDE_ADDR(pde));
ffffffffc0201fd4:	00093783          	ld	a5,0(s2)
    if (PPN(pa) >= npage) {
ffffffffc0201fd8:	000ab703          	ld	a4,0(s5)
    return pa2page(PDE_ADDR(pde));
ffffffffc0201fdc:	078a                	slli	a5,a5,0x2
ffffffffc0201fde:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc0201fe0:	18e7ff63          	bleu	a4,a5,ffffffffc020217e <vmm_init+0x456>
    return &pages[PPN(pa) - nbase];
ffffffffc0201fe4:	6008                	ld	a0,0(s0)
ffffffffc0201fe6:	414787b3          	sub	a5,a5,s4
ffffffffc0201fea:	079a                	slli	a5,a5,0x6
    free_page(pde2page(pd1[0]));
ffffffffc0201fec:	4585                	li	a1,1
ffffffffc0201fee:	953e                	add	a0,a0,a5
ffffffffc0201ff0:	c53fe0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    pgdir[0] = 0;
ffffffffc0201ff4:	00093023          	sd	zero,0(s2)
  asm volatile("sfence.vma");
ffffffffc0201ff8:	12000073          	sfence.vma
    flush_tlb();

    mm->pgdir = NULL;
ffffffffc0201ffc:	0004bc23          	sd	zero,24(s1)
    mm_destroy(mm);
ffffffffc0202000:	8526                	mv	a0,s1
ffffffffc0202002:	cf9ff0ef          	jal	ra,ffffffffc0201cfa <mm_destroy>
    check_mm_struct = NULL;
ffffffffc0202006:	00013797          	auipc	a5,0x13
ffffffffc020200a:	4e07b923          	sd	zero,1266(a5) # ffffffffc02154f8 <check_mm_struct>

    assert(nr_free_pages_store == nr_free_pages());
ffffffffc020200e:	c7bfe0ef          	jal	ra,ffffffffc0200c88 <nr_free_pages>
ffffffffc0202012:	1aa99263          	bne	s3,a0,ffffffffc02021b6 <vmm_init+0x48e>

    cprintf("check_pgfault() succeeded!\n");
ffffffffc0202016:	00004517          	auipc	a0,0x4
ffffffffc020201a:	16a50513          	addi	a0,a0,362 # ffffffffc0206180 <commands+0x1190>
ffffffffc020201e:	8b2fe0ef          	jal	ra,ffffffffc02000d0 <cprintf>
}
ffffffffc0202022:	7442                	ld	s0,48(sp)
ffffffffc0202024:	70e2                	ld	ra,56(sp)
ffffffffc0202026:	74a2                	ld	s1,40(sp)
ffffffffc0202028:	7902                	ld	s2,32(sp)
ffffffffc020202a:	69e2                	ld	s3,24(sp)
ffffffffc020202c:	6a42                	ld	s4,16(sp)
ffffffffc020202e:	6aa2                	ld	s5,8(sp)
    cprintf("check_vmm() succeeded.\n");
ffffffffc0202030:	00004517          	auipc	a0,0x4
ffffffffc0202034:	17050513          	addi	a0,a0,368 # ffffffffc02061a0 <commands+0x11b0>
}
ffffffffc0202038:	6121                	addi	sp,sp,64
    cprintf("check_vmm() succeeded.\n");
ffffffffc020203a:	896fe06f          	j	ffffffffc02000d0 <cprintf>
        assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
ffffffffc020203e:	00004697          	auipc	a3,0x4
ffffffffc0202042:	f7a68693          	addi	a3,a3,-134 # ffffffffc0205fb8 <commands+0xfc8>
ffffffffc0202046:	00004617          	auipc	a2,0x4
ffffffffc020204a:	94260613          	addi	a2,a2,-1726 # ffffffffc0205988 <commands+0x998>
ffffffffc020204e:	0d800593          	li	a1,216
ffffffffc0202052:	00004517          	auipc	a0,0x4
ffffffffc0202056:	e0e50513          	addi	a0,a0,-498 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020205a:	97cfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(vma1->vm_start == i  && vma1->vm_end == i  + 2);
ffffffffc020205e:	00004697          	auipc	a3,0x4
ffffffffc0202062:	fe268693          	addi	a3,a3,-30 # ffffffffc0206040 <commands+0x1050>
ffffffffc0202066:	00004617          	auipc	a2,0x4
ffffffffc020206a:	92260613          	addi	a2,a2,-1758 # ffffffffc0205988 <commands+0x998>
ffffffffc020206e:	0e800593          	li	a1,232
ffffffffc0202072:	00004517          	auipc	a0,0x4
ffffffffc0202076:	dee50513          	addi	a0,a0,-530 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020207a:	95cfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(vma2->vm_start == i  && vma2->vm_end == i  + 2);
ffffffffc020207e:	00004697          	auipc	a3,0x4
ffffffffc0202082:	ff268693          	addi	a3,a3,-14 # ffffffffc0206070 <commands+0x1080>
ffffffffc0202086:	00004617          	auipc	a2,0x4
ffffffffc020208a:	90260613          	addi	a2,a2,-1790 # ffffffffc0205988 <commands+0x998>
ffffffffc020208e:	0e900593          	li	a1,233
ffffffffc0202092:	00004517          	auipc	a0,0x4
ffffffffc0202096:	dce50513          	addi	a0,a0,-562 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020209a:	93cfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(vma != NULL);
ffffffffc020209e:	00004697          	auipc	a3,0x4
ffffffffc02020a2:	11a68693          	addi	a3,a3,282 # ffffffffc02061b8 <commands+0x11c8>
ffffffffc02020a6:	00004617          	auipc	a2,0x4
ffffffffc02020aa:	8e260613          	addi	a2,a2,-1822 # ffffffffc0205988 <commands+0x998>
ffffffffc02020ae:	10800593          	li	a1,264
ffffffffc02020b2:	00004517          	auipc	a0,0x4
ffffffffc02020b6:	dae50513          	addi	a0,a0,-594 # ffffffffc0205e60 <commands+0xe70>
ffffffffc02020ba:	91cfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(le != &(mm->mmap_list));
ffffffffc02020be:	00004697          	auipc	a3,0x4
ffffffffc02020c2:	ee268693          	addi	a3,a3,-286 # ffffffffc0205fa0 <commands+0xfb0>
ffffffffc02020c6:	00004617          	auipc	a2,0x4
ffffffffc02020ca:	8c260613          	addi	a2,a2,-1854 # ffffffffc0205988 <commands+0x998>
ffffffffc02020ce:	0d600593          	li	a1,214
ffffffffc02020d2:	00004517          	auipc	a0,0x4
ffffffffc02020d6:	d8e50513          	addi	a0,a0,-626 # ffffffffc0205e60 <commands+0xe70>
ffffffffc02020da:	8fcfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(vma3 == NULL);
ffffffffc02020de:	00004697          	auipc	a3,0x4
ffffffffc02020e2:	f3268693          	addi	a3,a3,-206 # ffffffffc0206010 <commands+0x1020>
ffffffffc02020e6:	00004617          	auipc	a2,0x4
ffffffffc02020ea:	8a260613          	addi	a2,a2,-1886 # ffffffffc0205988 <commands+0x998>
ffffffffc02020ee:	0e200593          	li	a1,226
ffffffffc02020f2:	00004517          	auipc	a0,0x4
ffffffffc02020f6:	d6e50513          	addi	a0,a0,-658 # ffffffffc0205e60 <commands+0xe70>
ffffffffc02020fa:	8dcfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(vma2 != NULL);
ffffffffc02020fe:	00004697          	auipc	a3,0x4
ffffffffc0202102:	f0268693          	addi	a3,a3,-254 # ffffffffc0206000 <commands+0x1010>
ffffffffc0202106:	00004617          	auipc	a2,0x4
ffffffffc020210a:	88260613          	addi	a2,a2,-1918 # ffffffffc0205988 <commands+0x998>
ffffffffc020210e:	0e000593          	li	a1,224
ffffffffc0202112:	00004517          	auipc	a0,0x4
ffffffffc0202116:	d4e50513          	addi	a0,a0,-690 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020211a:	8bcfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(vma1 != NULL);
ffffffffc020211e:	00004697          	auipc	a3,0x4
ffffffffc0202122:	ed268693          	addi	a3,a3,-302 # ffffffffc0205ff0 <commands+0x1000>
ffffffffc0202126:	00004617          	auipc	a2,0x4
ffffffffc020212a:	86260613          	addi	a2,a2,-1950 # ffffffffc0205988 <commands+0x998>
ffffffffc020212e:	0de00593          	li	a1,222
ffffffffc0202132:	00004517          	auipc	a0,0x4
ffffffffc0202136:	d2e50513          	addi	a0,a0,-722 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020213a:	89cfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(vma5 == NULL);
ffffffffc020213e:	00004697          	auipc	a3,0x4
ffffffffc0202142:	ef268693          	addi	a3,a3,-270 # ffffffffc0206030 <commands+0x1040>
ffffffffc0202146:	00004617          	auipc	a2,0x4
ffffffffc020214a:	84260613          	addi	a2,a2,-1982 # ffffffffc0205988 <commands+0x998>
ffffffffc020214e:	0e600593          	li	a1,230
ffffffffc0202152:	00004517          	auipc	a0,0x4
ffffffffc0202156:	d0e50513          	addi	a0,a0,-754 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020215a:	87cfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        assert(vma4 == NULL);
ffffffffc020215e:	00004697          	auipc	a3,0x4
ffffffffc0202162:	ec268693          	addi	a3,a3,-318 # ffffffffc0206020 <commands+0x1030>
ffffffffc0202166:	00004617          	auipc	a2,0x4
ffffffffc020216a:	82260613          	addi	a2,a2,-2014 # ffffffffc0205988 <commands+0x998>
ffffffffc020216e:	0e400593          	li	a1,228
ffffffffc0202172:	00004517          	auipc	a0,0x4
ffffffffc0202176:	cee50513          	addi	a0,a0,-786 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020217a:	85cfe0ef          	jal	ra,ffffffffc02001d6 <__panic>
        panic("pa2page called with invalid pa");
ffffffffc020217e:	00003617          	auipc	a2,0x3
ffffffffc0202182:	6ea60613          	addi	a2,a2,1770 # ffffffffc0205868 <commands+0x878>
ffffffffc0202186:	06200593          	li	a1,98
ffffffffc020218a:	00003517          	auipc	a0,0x3
ffffffffc020218e:	6fe50513          	addi	a0,a0,1790 # ffffffffc0205888 <commands+0x898>
ffffffffc0202192:	844fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(mm != NULL);
ffffffffc0202196:	00004697          	auipc	a3,0x4
ffffffffc020219a:	dfa68693          	addi	a3,a3,-518 # ffffffffc0205f90 <commands+0xfa0>
ffffffffc020219e:	00003617          	auipc	a2,0x3
ffffffffc02021a2:	7ea60613          	addi	a2,a2,2026 # ffffffffc0205988 <commands+0x998>
ffffffffc02021a6:	0c200593          	li	a1,194
ffffffffc02021aa:	00004517          	auipc	a0,0x4
ffffffffc02021ae:	cb650513          	addi	a0,a0,-842 # ffffffffc0205e60 <commands+0xe70>
ffffffffc02021b2:	824fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(nr_free_pages_store == nr_free_pages());
ffffffffc02021b6:	00004697          	auipc	a3,0x4
ffffffffc02021ba:	fa268693          	addi	a3,a3,-94 # ffffffffc0206158 <commands+0x1168>
ffffffffc02021be:	00003617          	auipc	a2,0x3
ffffffffc02021c2:	7ca60613          	addi	a2,a2,1994 # ffffffffc0205988 <commands+0x998>
ffffffffc02021c6:	12400593          	li	a1,292
ffffffffc02021ca:	00004517          	auipc	a0,0x4
ffffffffc02021ce:	c9650513          	addi	a0,a0,-874 # ffffffffc0205e60 <commands+0xe70>
ffffffffc02021d2:	804fe0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgdir[0] == 0);
ffffffffc02021d6:	00004697          	auipc	a3,0x4
ffffffffc02021da:	f4268693          	addi	a3,a3,-190 # ffffffffc0206118 <commands+0x1128>
ffffffffc02021de:	00003617          	auipc	a2,0x3
ffffffffc02021e2:	7aa60613          	addi	a2,a2,1962 # ffffffffc0205988 <commands+0x998>
ffffffffc02021e6:	10500593          	li	a1,261
ffffffffc02021ea:	00004517          	auipc	a0,0x4
ffffffffc02021ee:	c7650513          	addi	a0,a0,-906 # ffffffffc0205e60 <commands+0xe70>
ffffffffc02021f2:	fe5fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(find_vma(mm, addr) == vma);
ffffffffc02021f6:	00004697          	auipc	a3,0x4
ffffffffc02021fa:	f3268693          	addi	a3,a3,-206 # ffffffffc0206128 <commands+0x1138>
ffffffffc02021fe:	00003617          	auipc	a2,0x3
ffffffffc0202202:	78a60613          	addi	a2,a2,1930 # ffffffffc0205988 <commands+0x998>
ffffffffc0202206:	10d00593          	li	a1,269
ffffffffc020220a:	00004517          	auipc	a0,0x4
ffffffffc020220e:	c5650513          	addi	a0,a0,-938 # ffffffffc0205e60 <commands+0xe70>
ffffffffc0202212:	fc5fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
    return KADDR(page2pa(page));
ffffffffc0202216:	00003617          	auipc	a2,0x3
ffffffffc020221a:	61a60613          	addi	a2,a2,1562 # ffffffffc0205830 <commands+0x840>
ffffffffc020221e:	06900593          	li	a1,105
ffffffffc0202222:	00003517          	auipc	a0,0x3
ffffffffc0202226:	66650513          	addi	a0,a0,1638 # ffffffffc0205888 <commands+0x898>
ffffffffc020222a:	fadfd0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(sum == 0);
ffffffffc020222e:	00004697          	auipc	a3,0x4
ffffffffc0202232:	f1a68693          	addi	a3,a3,-230 # ffffffffc0206148 <commands+0x1158>
ffffffffc0202236:	00003617          	auipc	a2,0x3
ffffffffc020223a:	75260613          	addi	a2,a2,1874 # ffffffffc0205988 <commands+0x998>
ffffffffc020223e:	11700593          	li	a1,279
ffffffffc0202242:	00004517          	auipc	a0,0x4
ffffffffc0202246:	c1e50513          	addi	a0,a0,-994 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020224a:	f8dfd0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(check_mm_struct != NULL);
ffffffffc020224e:	00004697          	auipc	a3,0x4
ffffffffc0202252:	eb268693          	addi	a3,a3,-334 # ffffffffc0206100 <commands+0x1110>
ffffffffc0202256:	00003617          	auipc	a2,0x3
ffffffffc020225a:	73260613          	addi	a2,a2,1842 # ffffffffc0205988 <commands+0x998>
ffffffffc020225e:	10100593          	li	a1,257
ffffffffc0202262:	00004517          	auipc	a0,0x4
ffffffffc0202266:	bfe50513          	addi	a0,a0,-1026 # ffffffffc0205e60 <commands+0xe70>
ffffffffc020226a:	f6dfd0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc020226e <do_pgfault>:
 *            was a read (0) or write (1).
 *         -- The U/S flag (bit 2) indicates whether the processor was executing at user mode (1)
 *            or supervisor mode (0) at the time of the exception.
 */
int
do_pgfault(struct mm_struct *mm, uint32_t error_code, uintptr_t addr) {
ffffffffc020226e:	7139                	addi	sp,sp,-64
    int ret = -E_INVAL;
    //try to find a vma which include addr
    struct vma_struct *vma = find_vma(mm, addr);
ffffffffc0202270:	85b2                	mv	a1,a2
do_pgfault(struct mm_struct *mm, uint32_t error_code, uintptr_t addr) {
ffffffffc0202272:	f822                	sd	s0,48(sp)
ffffffffc0202274:	f426                	sd	s1,40(sp)
ffffffffc0202276:	fc06                	sd	ra,56(sp)
ffffffffc0202278:	f04a                	sd	s2,32(sp)
ffffffffc020227a:	ec4e                	sd	s3,24(sp)
ffffffffc020227c:	8432                	mv	s0,a2
ffffffffc020227e:	84aa                	mv	s1,a0
    struct vma_struct *vma = find_vma(mm, addr);
ffffffffc0202280:	96fff0ef          	jal	ra,ffffffffc0201bee <find_vma>

    pgfault_num++;
ffffffffc0202284:	00013797          	auipc	a5,0x13
ffffffffc0202288:	20c78793          	addi	a5,a5,524 # ffffffffc0215490 <pgfault_num>
ffffffffc020228c:	439c                	lw	a5,0(a5)
ffffffffc020228e:	2785                	addiw	a5,a5,1
ffffffffc0202290:	00013717          	auipc	a4,0x13
ffffffffc0202294:	20f72023          	sw	a5,512(a4) # ffffffffc0215490 <pgfault_num>
    //If the addr is in the range of a mm's vma?
    if (vma == NULL || vma->vm_start > addr) {
ffffffffc0202298:	c555                	beqz	a0,ffffffffc0202344 <do_pgfault+0xd6>
ffffffffc020229a:	651c                	ld	a5,8(a0)
ffffffffc020229c:	0af46463          	bltu	s0,a5,ffffffffc0202344 <do_pgfault+0xd6>
     *    (read  an non_existed addr && addr is readable)
     * THEN
     *    continue process
     */
    uint32_t perm = PTE_U;
    if (vma->vm_flags & VM_WRITE) {
ffffffffc02022a0:	4d1c                	lw	a5,24(a0)
    uint32_t perm = PTE_U;
ffffffffc02022a2:	49c1                	li	s3,16
    if (vma->vm_flags & VM_WRITE) {
ffffffffc02022a4:	8b89                	andi	a5,a5,2
ffffffffc02022a6:	e3a5                	bnez	a5,ffffffffc0202306 <do_pgfault+0x98>
        perm |= READ_WRITE;
    }
    addr = ROUNDDOWN(addr, PGSIZE);
ffffffffc02022a8:	767d                	lui	a2,0xfffff

    pte_t *ptep=NULL;
  
    // try to find a pte, if pte's PT(Page Table) isn't existed, then create a PT.
    // (notice the 3th parameter '1')
    if ((ptep = get_pte(mm->pgdir, addr, 1)) == NULL) {
ffffffffc02022aa:	6c88                	ld	a0,24(s1)
    addr = ROUNDDOWN(addr, PGSIZE);
ffffffffc02022ac:	8c71                	and	s0,s0,a2
    if ((ptep = get_pte(mm->pgdir, addr, 1)) == NULL) {
ffffffffc02022ae:	85a2                	mv	a1,s0
ffffffffc02022b0:	4605                	li	a2,1
ffffffffc02022b2:	a17fe0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
ffffffffc02022b6:	c945                	beqz	a0,ffffffffc0202366 <do_pgfault+0xf8>
        cprintf("get_pte in do_pgfault failed\n");
        goto failed;
    }
    if (*ptep == 0) { // if the phy addr isn't exist, then alloc a page & map the phy addr with logical addr
ffffffffc02022b8:	610c                	ld	a1,0(a0)
ffffffffc02022ba:	c5b5                	beqz	a1,ffffffffc0202326 <do_pgfault+0xb8>
        *    swap_in(mm, addr, &page) : 分配一个内存页，然后根据
        *    PTE中的swap条目的addr，找到磁盘页的地址，将磁盘页的内容读入这个内存页
        *    page_insert ： 建立一个Page的phy addr与线性addr la的映射
        *    swap_map_swappable ： 设置页面可交换
        */
       if(swap_init_ok) {
ffffffffc02022bc:	00013797          	auipc	a5,0x13
ffffffffc02022c0:	1e478793          	addi	a5,a5,484 # ffffffffc02154a0 <swap_init_ok>
ffffffffc02022c4:	439c                	lw	a5,0(a5)
ffffffffc02022c6:	2781                	sext.w	a5,a5
ffffffffc02022c8:	c7d9                	beqz	a5,ffffffffc0202356 <do_pgfault+0xe8>
            struct Page *page=NULL;
            if ((ret = swap_in(mm, addr, &page)) != 0) {
ffffffffc02022ca:	0030                	addi	a2,sp,8
ffffffffc02022cc:	85a2                	mv	a1,s0
ffffffffc02022ce:	8526                	mv	a0,s1
            struct Page *page=NULL;
ffffffffc02022d0:	e402                	sd	zero,8(sp)
            if ((ret = swap_in(mm, addr, &page)) != 0) {
ffffffffc02022d2:	14d000ef          	jal	ra,ffffffffc0202c1e <swap_in>
ffffffffc02022d6:	892a                	mv	s2,a0
ffffffffc02022d8:	e90d                	bnez	a0,ffffffffc020230a <do_pgfault+0x9c>
                cprintf("swap_in in do_pgfault failed\n");
                goto failed;
            }    
            page_insert(mm->pgdir, page, addr, perm);
ffffffffc02022da:	65a2                	ld	a1,8(sp)
ffffffffc02022dc:	6c88                	ld	a0,24(s1)
ffffffffc02022de:	86ce                	mv	a3,s3
ffffffffc02022e0:	8622                	mv	a2,s0
ffffffffc02022e2:	c8ffe0ef          	jal	ra,ffffffffc0200f70 <page_insert>
            swap_map_swappable(mm, addr, page, 1);
ffffffffc02022e6:	6622                	ld	a2,8(sp)
ffffffffc02022e8:	4685                	li	a3,1
ffffffffc02022ea:	85a2                	mv	a1,s0
ffffffffc02022ec:	8526                	mv	a0,s1
ffffffffc02022ee:	00d000ef          	jal	ra,ffffffffc0202afa <swap_map_swappable>
            page->pra_vaddr = addr;
ffffffffc02022f2:	67a2                	ld	a5,8(sp)
ffffffffc02022f4:	ff80                	sd	s0,56(a5)
   }

   ret = 0;
failed:
    return ret;
}
ffffffffc02022f6:	70e2                	ld	ra,56(sp)
ffffffffc02022f8:	7442                	ld	s0,48(sp)
ffffffffc02022fa:	854a                	mv	a0,s2
ffffffffc02022fc:	74a2                	ld	s1,40(sp)
ffffffffc02022fe:	7902                	ld	s2,32(sp)
ffffffffc0202300:	69e2                	ld	s3,24(sp)
ffffffffc0202302:	6121                	addi	sp,sp,64
ffffffffc0202304:	8082                	ret
        perm |= READ_WRITE;
ffffffffc0202306:	49dd                	li	s3,23
ffffffffc0202308:	b745                	j	ffffffffc02022a8 <do_pgfault+0x3a>
                cprintf("swap_in in do_pgfault failed\n");
ffffffffc020230a:	00004517          	auipc	a0,0x4
ffffffffc020230e:	bde50513          	addi	a0,a0,-1058 # ffffffffc0205ee8 <commands+0xef8>
ffffffffc0202312:	dbffd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
}
ffffffffc0202316:	70e2                	ld	ra,56(sp)
ffffffffc0202318:	7442                	ld	s0,48(sp)
ffffffffc020231a:	854a                	mv	a0,s2
ffffffffc020231c:	74a2                	ld	s1,40(sp)
ffffffffc020231e:	7902                	ld	s2,32(sp)
ffffffffc0202320:	69e2                	ld	s3,24(sp)
ffffffffc0202322:	6121                	addi	sp,sp,64
ffffffffc0202324:	8082                	ret
        if (pgdir_alloc_page(mm->pgdir, addr, perm) == NULL) {
ffffffffc0202326:	6c88                	ld	a0,24(s1)
ffffffffc0202328:	864e                	mv	a2,s3
ffffffffc020232a:	85a2                	mv	a1,s0
ffffffffc020232c:	f92ff0ef          	jal	ra,ffffffffc0201abe <pgdir_alloc_page>
   ret = 0;
ffffffffc0202330:	4901                	li	s2,0
        if (pgdir_alloc_page(mm->pgdir, addr, perm) == NULL) {
ffffffffc0202332:	f171                	bnez	a0,ffffffffc02022f6 <do_pgfault+0x88>
            cprintf("pgdir_alloc_page in do_pgfault failed\n");
ffffffffc0202334:	00004517          	auipc	a0,0x4
ffffffffc0202338:	b8c50513          	addi	a0,a0,-1140 # ffffffffc0205ec0 <commands+0xed0>
ffffffffc020233c:	d95fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    ret = -E_NO_MEM;
ffffffffc0202340:	5971                	li	s2,-4
            goto failed;
ffffffffc0202342:	bf55                	j	ffffffffc02022f6 <do_pgfault+0x88>
        cprintf("not valid addr %x, and  can not find it in vma\n", addr);
ffffffffc0202344:	85a2                	mv	a1,s0
ffffffffc0202346:	00004517          	auipc	a0,0x4
ffffffffc020234a:	b2a50513          	addi	a0,a0,-1238 # ffffffffc0205e70 <commands+0xe80>
ffffffffc020234e:	d83fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    int ret = -E_INVAL;
ffffffffc0202352:	5975                	li	s2,-3
        goto failed;
ffffffffc0202354:	b74d                	j	ffffffffc02022f6 <do_pgfault+0x88>
            cprintf("no swap_init_ok but ptep is %x, failed\n", *ptep);
ffffffffc0202356:	00004517          	auipc	a0,0x4
ffffffffc020235a:	bb250513          	addi	a0,a0,-1102 # ffffffffc0205f08 <commands+0xf18>
ffffffffc020235e:	d73fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    ret = -E_NO_MEM;
ffffffffc0202362:	5971                	li	s2,-4
            goto failed;
ffffffffc0202364:	bf49                	j	ffffffffc02022f6 <do_pgfault+0x88>
        cprintf("get_pte in do_pgfault failed\n");
ffffffffc0202366:	00004517          	auipc	a0,0x4
ffffffffc020236a:	b3a50513          	addi	a0,a0,-1222 # ffffffffc0205ea0 <commands+0xeb0>
ffffffffc020236e:	d63fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    ret = -E_NO_MEM;
ffffffffc0202372:	5971                	li	s2,-4
        goto failed;
ffffffffc0202374:	b749                	j	ffffffffc02022f6 <do_pgfault+0x88>

ffffffffc0202376 <swap_init>:

static void check_swap(void);

int
swap_init(void)
{
ffffffffc0202376:	7135                	addi	sp,sp,-160
ffffffffc0202378:	ed06                	sd	ra,152(sp)
ffffffffc020237a:	e922                	sd	s0,144(sp)
ffffffffc020237c:	e526                	sd	s1,136(sp)
ffffffffc020237e:	e14a                	sd	s2,128(sp)
ffffffffc0202380:	fcce                	sd	s3,120(sp)
ffffffffc0202382:	f8d2                	sd	s4,112(sp)
ffffffffc0202384:	f4d6                	sd	s5,104(sp)
ffffffffc0202386:	f0da                	sd	s6,96(sp)
ffffffffc0202388:	ecde                	sd	s7,88(sp)
ffffffffc020238a:	e8e2                	sd	s8,80(sp)
ffffffffc020238c:	e4e6                	sd	s9,72(sp)
ffffffffc020238e:	e0ea                	sd	s10,64(sp)
ffffffffc0202390:	fc6e                	sd	s11,56(sp)
     swapfs_init();
ffffffffc0202392:	4cb010ef          	jal	ra,ffffffffc020405c <swapfs_init>
     // if (!(1024 <= max_swap_offset && max_swap_offset < MAX_SWAP_OFFSET_LIMIT))
     // {
     //      panic("bad max_swap_offset %08x.\n", max_swap_offset);
     // }
     // Since the IDE is faked, it can only store 7 pages at most to pass the test
     if (!(7 <= max_swap_offset &&
ffffffffc0202396:	00013797          	auipc	a5,0x13
ffffffffc020239a:	1f278793          	addi	a5,a5,498 # ffffffffc0215588 <max_swap_offset>
ffffffffc020239e:	6394                	ld	a3,0(a5)
ffffffffc02023a0:	010007b7          	lui	a5,0x1000
ffffffffc02023a4:	17e1                	addi	a5,a5,-8
ffffffffc02023a6:	ff968713          	addi	a4,a3,-7
ffffffffc02023aa:	4ae7e863          	bltu	a5,a4,ffffffffc020285a <swap_init+0x4e4>
        max_swap_offset < MAX_SWAP_OFFSET_LIMIT)) {
        panic("bad max_swap_offset %08x.\n", max_swap_offset);
     }

     sm = &swap_manager_fifo;
ffffffffc02023ae:	00008797          	auipc	a5,0x8
ffffffffc02023b2:	c6278793          	addi	a5,a5,-926 # ffffffffc020a010 <swap_manager_fifo>
     int r = sm->init();
ffffffffc02023b6:	6798                	ld	a4,8(a5)
     sm = &swap_manager_fifo;
ffffffffc02023b8:	00013697          	auipc	a3,0x13
ffffffffc02023bc:	0ef6b023          	sd	a5,224(a3) # ffffffffc0215498 <sm>
     int r = sm->init();
ffffffffc02023c0:	9702                	jalr	a4
ffffffffc02023c2:	8aaa                	mv	s5,a0
     
     if (r == 0)
ffffffffc02023c4:	c10d                	beqz	a0,ffffffffc02023e6 <swap_init+0x70>
          cprintf("SWAP: manager = %s\n", sm->name);
          check_swap();
     }

     return r;
}
ffffffffc02023c6:	60ea                	ld	ra,152(sp)
ffffffffc02023c8:	644a                	ld	s0,144(sp)
ffffffffc02023ca:	8556                	mv	a0,s5
ffffffffc02023cc:	64aa                	ld	s1,136(sp)
ffffffffc02023ce:	690a                	ld	s2,128(sp)
ffffffffc02023d0:	79e6                	ld	s3,120(sp)
ffffffffc02023d2:	7a46                	ld	s4,112(sp)
ffffffffc02023d4:	7aa6                	ld	s5,104(sp)
ffffffffc02023d6:	7b06                	ld	s6,96(sp)
ffffffffc02023d8:	6be6                	ld	s7,88(sp)
ffffffffc02023da:	6c46                	ld	s8,80(sp)
ffffffffc02023dc:	6ca6                	ld	s9,72(sp)
ffffffffc02023de:	6d06                	ld	s10,64(sp)
ffffffffc02023e0:	7de2                	ld	s11,56(sp)
ffffffffc02023e2:	610d                	addi	sp,sp,160
ffffffffc02023e4:	8082                	ret
          cprintf("SWAP: manager = %s\n", sm->name);
ffffffffc02023e6:	00013797          	auipc	a5,0x13
ffffffffc02023ea:	0b278793          	addi	a5,a5,178 # ffffffffc0215498 <sm>
ffffffffc02023ee:	639c                	ld	a5,0(a5)
ffffffffc02023f0:	00004517          	auipc	a0,0x4
ffffffffc02023f4:	e5850513          	addi	a0,a0,-424 # ffffffffc0206248 <commands+0x1258>
ffffffffc02023f8:	00013417          	auipc	s0,0x13
ffffffffc02023fc:	1e040413          	addi	s0,s0,480 # ffffffffc02155d8 <free_area>
ffffffffc0202400:	638c                	ld	a1,0(a5)
          swap_init_ok = 1;
ffffffffc0202402:	4785                	li	a5,1
ffffffffc0202404:	00013717          	auipc	a4,0x13
ffffffffc0202408:	08f72e23          	sw	a5,156(a4) # ffffffffc02154a0 <swap_init_ok>
          cprintf("SWAP: manager = %s\n", sm->name);
ffffffffc020240c:	cc5fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
ffffffffc0202410:	641c                	ld	a5,8(s0)
check_swap(void)
{
    //backup mem env
     int ret, count = 0, total = 0, i;
     list_entry_t *le = &free_list;
     while ((le = list_next(le)) != &free_list) {
ffffffffc0202412:	36878863          	beq	a5,s0,ffffffffc0202782 <swap_init+0x40c>
 * test_bit - Determine whether a bit is set
 * @nr:     the bit to test
 * @addr:   the address to count from
 * */
static inline bool test_bit(int nr, volatile void *addr) {
    return (((*(volatile unsigned long *)addr) >> nr) & 1);
ffffffffc0202416:	ff07b703          	ld	a4,-16(a5)
ffffffffc020241a:	8305                	srli	a4,a4,0x1
        struct Page *p = le2page(le, page_link);
        assert(PageProperty(p));
ffffffffc020241c:	8b05                	andi	a4,a4,1
ffffffffc020241e:	36070663          	beqz	a4,ffffffffc020278a <swap_init+0x414>
     int ret, count = 0, total = 0, i;
ffffffffc0202422:	4481                	li	s1,0
ffffffffc0202424:	4901                	li	s2,0
ffffffffc0202426:	a031                	j	ffffffffc0202432 <swap_init+0xbc>
ffffffffc0202428:	ff07b703          	ld	a4,-16(a5)
        assert(PageProperty(p));
ffffffffc020242c:	8b09                	andi	a4,a4,2
ffffffffc020242e:	34070e63          	beqz	a4,ffffffffc020278a <swap_init+0x414>
        count ++, total += p->property;
ffffffffc0202432:	ff87a703          	lw	a4,-8(a5)
ffffffffc0202436:	679c                	ld	a5,8(a5)
ffffffffc0202438:	2905                	addiw	s2,s2,1
ffffffffc020243a:	9cb9                	addw	s1,s1,a4
     while ((le = list_next(le)) != &free_list) {
ffffffffc020243c:	fe8796e3          	bne	a5,s0,ffffffffc0202428 <swap_init+0xb2>
ffffffffc0202440:	89a6                	mv	s3,s1
     }
     assert(total == nr_free_pages());
ffffffffc0202442:	847fe0ef          	jal	ra,ffffffffc0200c88 <nr_free_pages>
ffffffffc0202446:	69351263          	bne	a0,s3,ffffffffc0202aca <swap_init+0x754>
     cprintf("BEGIN check_swap: count %d, total %d\n",count,total);
ffffffffc020244a:	8626                	mv	a2,s1
ffffffffc020244c:	85ca                	mv	a1,s2
ffffffffc020244e:	00004517          	auipc	a0,0x4
ffffffffc0202452:	e4250513          	addi	a0,a0,-446 # ffffffffc0206290 <commands+0x12a0>
ffffffffc0202456:	c7bfd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
     
     //now we set the phy pages env     
     struct mm_struct *mm = mm_create();
ffffffffc020245a:	f1aff0ef          	jal	ra,ffffffffc0201b74 <mm_create>
ffffffffc020245e:	8baa                	mv	s7,a0
     assert(mm != NULL);
ffffffffc0202460:	60050563          	beqz	a0,ffffffffc0202a6a <swap_init+0x6f4>

     extern struct mm_struct *check_mm_struct;
     assert(check_mm_struct == NULL);
ffffffffc0202464:	00013797          	auipc	a5,0x13
ffffffffc0202468:	09478793          	addi	a5,a5,148 # ffffffffc02154f8 <check_mm_struct>
ffffffffc020246c:	639c                	ld	a5,0(a5)
ffffffffc020246e:	60079e63          	bnez	a5,ffffffffc0202a8a <swap_init+0x714>

     check_mm_struct = mm;

     pde_t *pgdir = mm->pgdir = boot_pgdir;
ffffffffc0202472:	00013797          	auipc	a5,0x13
ffffffffc0202476:	00e78793          	addi	a5,a5,14 # ffffffffc0215480 <boot_pgdir>
ffffffffc020247a:	0007bb03          	ld	s6,0(a5)
     check_mm_struct = mm;
ffffffffc020247e:	00013797          	auipc	a5,0x13
ffffffffc0202482:	06a7bd23          	sd	a0,122(a5) # ffffffffc02154f8 <check_mm_struct>
     assert(pgdir[0] == 0);
ffffffffc0202486:	000b3783          	ld	a5,0(s6)
     pde_t *pgdir = mm->pgdir = boot_pgdir;
ffffffffc020248a:	01653c23          	sd	s6,24(a0)
     assert(pgdir[0] == 0);
ffffffffc020248e:	4e079263          	bnez	a5,ffffffffc0202972 <swap_init+0x5fc>

     struct vma_struct *vma = vma_create(BEING_CHECK_VALID_VADDR, CHECK_VALID_VADDR, VM_WRITE | VM_READ);
ffffffffc0202492:	6599                	lui	a1,0x6
ffffffffc0202494:	460d                	li	a2,3
ffffffffc0202496:	6505                	lui	a0,0x1
ffffffffc0202498:	f28ff0ef          	jal	ra,ffffffffc0201bc0 <vma_create>
ffffffffc020249c:	85aa                	mv	a1,a0
     assert(vma != NULL);
ffffffffc020249e:	4e050a63          	beqz	a0,ffffffffc0202992 <swap_init+0x61c>

     insert_vma_struct(mm, vma);
ffffffffc02024a2:	855e                	mv	a0,s7
ffffffffc02024a4:	f88ff0ef          	jal	ra,ffffffffc0201c2c <insert_vma_struct>

     //setup the temp Page Table vaddr 0~4MB
     cprintf("setup Page Table for vaddr 0X1000, so alloc a page\n");
ffffffffc02024a8:	00004517          	auipc	a0,0x4
ffffffffc02024ac:	e2850513          	addi	a0,a0,-472 # ffffffffc02062d0 <commands+0x12e0>
ffffffffc02024b0:	c21fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
     pte_t *temp_ptep=NULL;
     temp_ptep = get_pte(mm->pgdir, BEING_CHECK_VALID_VADDR, 1);
ffffffffc02024b4:	018bb503          	ld	a0,24(s7)
ffffffffc02024b8:	4605                	li	a2,1
ffffffffc02024ba:	6585                	lui	a1,0x1
ffffffffc02024bc:	80dfe0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
     assert(temp_ptep!= NULL);
ffffffffc02024c0:	4e050963          	beqz	a0,ffffffffc02029b2 <swap_init+0x63c>
     cprintf("setup Page Table vaddr 0~4MB OVER!\n");
ffffffffc02024c4:	00004517          	auipc	a0,0x4
ffffffffc02024c8:	e5c50513          	addi	a0,a0,-420 # ffffffffc0206320 <commands+0x1330>
ffffffffc02024cc:	00013997          	auipc	s3,0x13
ffffffffc02024d0:	03498993          	addi	s3,s3,52 # ffffffffc0215500 <check_rp>
ffffffffc02024d4:	bfdfd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
     
     for (i=0;i<CHECK_VALID_PHY_PAGE_NUM;i++) {
ffffffffc02024d8:	00013a17          	auipc	s4,0x13
ffffffffc02024dc:	048a0a13          	addi	s4,s4,72 # ffffffffc0215520 <swap_in_seq_no>
     cprintf("setup Page Table vaddr 0~4MB OVER!\n");
ffffffffc02024e0:	8c4e                	mv	s8,s3
          check_rp[i] = alloc_page();
ffffffffc02024e2:	4505                	li	a0,1
ffffffffc02024e4:	ed6fe0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02024e8:	00ac3023          	sd	a0,0(s8)
          assert(check_rp[i] != NULL );
ffffffffc02024ec:	32050763          	beqz	a0,ffffffffc020281a <swap_init+0x4a4>
ffffffffc02024f0:	651c                	ld	a5,8(a0)
          assert(!PageProperty(check_rp[i]));
ffffffffc02024f2:	8b89                	andi	a5,a5,2
ffffffffc02024f4:	30079363          	bnez	a5,ffffffffc02027fa <swap_init+0x484>
ffffffffc02024f8:	0c21                	addi	s8,s8,8
     for (i=0;i<CHECK_VALID_PHY_PAGE_NUM;i++) {
ffffffffc02024fa:	ff4c14e3          	bne	s8,s4,ffffffffc02024e2 <swap_init+0x16c>
     }
     list_entry_t free_list_store = free_list;
ffffffffc02024fe:	601c                	ld	a5,0(s0)
     assert(list_empty(&free_list));
     
     //assert(alloc_page() == NULL);
     
     unsigned int nr_free_store = nr_free;
     nr_free = 0;
ffffffffc0202500:	00013c17          	auipc	s8,0x13
ffffffffc0202504:	000c0c13          	mv	s8,s8
     list_entry_t free_list_store = free_list;
ffffffffc0202508:	ec3e                	sd	a5,24(sp)
ffffffffc020250a:	641c                	ld	a5,8(s0)
ffffffffc020250c:	f03e                	sd	a5,32(sp)
     unsigned int nr_free_store = nr_free;
ffffffffc020250e:	481c                	lw	a5,16(s0)
ffffffffc0202510:	f43e                	sd	a5,40(sp)
    elm->prev = elm->next = elm;
ffffffffc0202512:	00013797          	auipc	a5,0x13
ffffffffc0202516:	0c87b723          	sd	s0,206(a5) # ffffffffc02155e0 <free_area+0x8>
ffffffffc020251a:	00013797          	auipc	a5,0x13
ffffffffc020251e:	0a87bf23          	sd	s0,190(a5) # ffffffffc02155d8 <free_area>
     nr_free = 0;
ffffffffc0202522:	00013797          	auipc	a5,0x13
ffffffffc0202526:	0c07a323          	sw	zero,198(a5) # ffffffffc02155e8 <free_area+0x10>
     for (i=0;i<CHECK_VALID_PHY_PAGE_NUM;i++) {
        free_pages(check_rp[i],1);
ffffffffc020252a:	000c3503          	ld	a0,0(s8) # ffffffffc0215500 <check_rp>
ffffffffc020252e:	4585                	li	a1,1
ffffffffc0202530:	0c21                	addi	s8,s8,8
ffffffffc0202532:	f10fe0ef          	jal	ra,ffffffffc0200c42 <free_pages>
     for (i=0;i<CHECK_VALID_PHY_PAGE_NUM;i++) {
ffffffffc0202536:	ff4c1ae3          	bne	s8,s4,ffffffffc020252a <swap_init+0x1b4>
     }
     assert(nr_free==CHECK_VALID_PHY_PAGE_NUM);
ffffffffc020253a:	01042c03          	lw	s8,16(s0)
ffffffffc020253e:	4791                	li	a5,4
ffffffffc0202540:	50fc1563          	bne	s8,a5,ffffffffc0202a4a <swap_init+0x6d4>
     
     cprintf("set up init env for check_swap begin!\n");
ffffffffc0202544:	00004517          	auipc	a0,0x4
ffffffffc0202548:	e6450513          	addi	a0,a0,-412 # ffffffffc02063a8 <commands+0x13b8>
ffffffffc020254c:	b85fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
     *(unsigned char *)0x1000 = 0x0a;
ffffffffc0202550:	6685                	lui	a3,0x1
     //setup initial vir_page<->phy_page environment for page relpacement algorithm 

     
     pgfault_num=0;
ffffffffc0202552:	00013797          	auipc	a5,0x13
ffffffffc0202556:	f207af23          	sw	zero,-194(a5) # ffffffffc0215490 <pgfault_num>
     *(unsigned char *)0x1000 = 0x0a;
ffffffffc020255a:	4629                	li	a2,10
     pgfault_num=0;
ffffffffc020255c:	00013797          	auipc	a5,0x13
ffffffffc0202560:	f3478793          	addi	a5,a5,-204 # ffffffffc0215490 <pgfault_num>
     *(unsigned char *)0x1000 = 0x0a;
ffffffffc0202564:	00c68023          	sb	a2,0(a3) # 1000 <BASE_ADDRESS-0xffffffffc01ff000>
     assert(pgfault_num==1);
ffffffffc0202568:	4398                	lw	a4,0(a5)
ffffffffc020256a:	4585                	li	a1,1
ffffffffc020256c:	2701                	sext.w	a4,a4
ffffffffc020256e:	38b71263          	bne	a4,a1,ffffffffc02028f2 <swap_init+0x57c>
     *(unsigned char *)0x1010 = 0x0a;
ffffffffc0202572:	00c68823          	sb	a2,16(a3)
     assert(pgfault_num==1);
ffffffffc0202576:	4394                	lw	a3,0(a5)
ffffffffc0202578:	2681                	sext.w	a3,a3
ffffffffc020257a:	38e69c63          	bne	a3,a4,ffffffffc0202912 <swap_init+0x59c>
     *(unsigned char *)0x2000 = 0x0b;
ffffffffc020257e:	6689                	lui	a3,0x2
ffffffffc0202580:	462d                	li	a2,11
ffffffffc0202582:	00c68023          	sb	a2,0(a3) # 2000 <BASE_ADDRESS-0xffffffffc01fe000>
     assert(pgfault_num==2);
ffffffffc0202586:	4398                	lw	a4,0(a5)
ffffffffc0202588:	4589                	li	a1,2
ffffffffc020258a:	2701                	sext.w	a4,a4
ffffffffc020258c:	2eb71363          	bne	a4,a1,ffffffffc0202872 <swap_init+0x4fc>
     *(unsigned char *)0x2010 = 0x0b;
ffffffffc0202590:	00c68823          	sb	a2,16(a3)
     assert(pgfault_num==2);
ffffffffc0202594:	4394                	lw	a3,0(a5)
ffffffffc0202596:	2681                	sext.w	a3,a3
ffffffffc0202598:	2ee69d63          	bne	a3,a4,ffffffffc0202892 <swap_init+0x51c>
     *(unsigned char *)0x3000 = 0x0c;
ffffffffc020259c:	668d                	lui	a3,0x3
ffffffffc020259e:	4631                	li	a2,12
ffffffffc02025a0:	00c68023          	sb	a2,0(a3) # 3000 <BASE_ADDRESS-0xffffffffc01fd000>
     assert(pgfault_num==3);
ffffffffc02025a4:	4398                	lw	a4,0(a5)
ffffffffc02025a6:	458d                	li	a1,3
ffffffffc02025a8:	2701                	sext.w	a4,a4
ffffffffc02025aa:	30b71463          	bne	a4,a1,ffffffffc02028b2 <swap_init+0x53c>
     *(unsigned char *)0x3010 = 0x0c;
ffffffffc02025ae:	00c68823          	sb	a2,16(a3)
     assert(pgfault_num==3);
ffffffffc02025b2:	4394                	lw	a3,0(a5)
ffffffffc02025b4:	2681                	sext.w	a3,a3
ffffffffc02025b6:	30e69e63          	bne	a3,a4,ffffffffc02028d2 <swap_init+0x55c>
     *(unsigned char *)0x4000 = 0x0d;
ffffffffc02025ba:	6691                	lui	a3,0x4
ffffffffc02025bc:	4635                	li	a2,13
ffffffffc02025be:	00c68023          	sb	a2,0(a3) # 4000 <BASE_ADDRESS-0xffffffffc01fc000>
     assert(pgfault_num==4);
ffffffffc02025c2:	4398                	lw	a4,0(a5)
ffffffffc02025c4:	2701                	sext.w	a4,a4
ffffffffc02025c6:	37871663          	bne	a4,s8,ffffffffc0202932 <swap_init+0x5bc>
     *(unsigned char *)0x4010 = 0x0d;
ffffffffc02025ca:	00c68823          	sb	a2,16(a3)
     assert(pgfault_num==4);
ffffffffc02025ce:	439c                	lw	a5,0(a5)
ffffffffc02025d0:	2781                	sext.w	a5,a5
ffffffffc02025d2:	38e79063          	bne	a5,a4,ffffffffc0202952 <swap_init+0x5dc>
     
     check_content_set();
     assert( nr_free == 0);         
ffffffffc02025d6:	481c                	lw	a5,16(s0)
ffffffffc02025d8:	3e079d63          	bnez	a5,ffffffffc02029d2 <swap_init+0x65c>
ffffffffc02025dc:	00013797          	auipc	a5,0x13
ffffffffc02025e0:	f4478793          	addi	a5,a5,-188 # ffffffffc0215520 <swap_in_seq_no>
ffffffffc02025e4:	00013717          	auipc	a4,0x13
ffffffffc02025e8:	f6470713          	addi	a4,a4,-156 # ffffffffc0215548 <swap_out_seq_no>
ffffffffc02025ec:	00013617          	auipc	a2,0x13
ffffffffc02025f0:	f5c60613          	addi	a2,a2,-164 # ffffffffc0215548 <swap_out_seq_no>
     for(i = 0; i<MAX_SEQ_NO ; i++) 
         swap_out_seq_no[i]=swap_in_seq_no[i]=-1;
ffffffffc02025f4:	56fd                	li	a3,-1
ffffffffc02025f6:	c394                	sw	a3,0(a5)
ffffffffc02025f8:	c314                	sw	a3,0(a4)
ffffffffc02025fa:	0791                	addi	a5,a5,4
ffffffffc02025fc:	0711                	addi	a4,a4,4
     for(i = 0; i<MAX_SEQ_NO ; i++) 
ffffffffc02025fe:	fef61ce3          	bne	a2,a5,ffffffffc02025f6 <swap_init+0x280>
ffffffffc0202602:	00013697          	auipc	a3,0x13
ffffffffc0202606:	fa668693          	addi	a3,a3,-90 # ffffffffc02155a8 <check_ptep>
ffffffffc020260a:	00013817          	auipc	a6,0x13
ffffffffc020260e:	ef680813          	addi	a6,a6,-266 # ffffffffc0215500 <check_rp>
ffffffffc0202612:	6d05                	lui	s10,0x1
    if (PPN(pa) >= npage) {
ffffffffc0202614:	00013c97          	auipc	s9,0x13
ffffffffc0202618:	e74c8c93          	addi	s9,s9,-396 # ffffffffc0215488 <npage>
    return &pages[PPN(pa) - nbase];
ffffffffc020261c:	00005d97          	auipc	s11,0x5
ffffffffc0202620:	984d8d93          	addi	s11,s11,-1660 # ffffffffc0206fa0 <nbase>
ffffffffc0202624:	00013c17          	auipc	s8,0x13
ffffffffc0202628:	eccc0c13          	addi	s8,s8,-308 # ffffffffc02154f0 <pages>
     
     for (i= 0;i<CHECK_VALID_PHY_PAGE_NUM;i++) {
         check_ptep[i]=0;
ffffffffc020262c:	0006b023          	sd	zero,0(a3)
         check_ptep[i] = get_pte(pgdir, (i+1)*0x1000, 0);
ffffffffc0202630:	4601                	li	a2,0
ffffffffc0202632:	85ea                	mv	a1,s10
ffffffffc0202634:	855a                	mv	a0,s6
ffffffffc0202636:	e842                	sd	a6,16(sp)
         check_ptep[i]=0;
ffffffffc0202638:	e436                	sd	a3,8(sp)
         check_ptep[i] = get_pte(pgdir, (i+1)*0x1000, 0);
ffffffffc020263a:	e8efe0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
ffffffffc020263e:	66a2                	ld	a3,8(sp)
         //cprintf("i %d, check_ptep addr %x, value %x\n", i, check_ptep[i], *check_ptep[i]);
         assert(check_ptep[i] != NULL);
ffffffffc0202640:	6842                	ld	a6,16(sp)
         check_ptep[i] = get_pte(pgdir, (i+1)*0x1000, 0);
ffffffffc0202642:	e288                	sd	a0,0(a3)
         assert(check_ptep[i] != NULL);
ffffffffc0202644:	1e050b63          	beqz	a0,ffffffffc020283a <swap_init+0x4c4>
         assert(pte2page(*check_ptep[i]) == check_rp[i]);
ffffffffc0202648:	611c                	ld	a5,0(a0)
    if (!(pte & PTE_V)) {
ffffffffc020264a:	0017f613          	andi	a2,a5,1
ffffffffc020264e:	18060a63          	beqz	a2,ffffffffc02027e2 <swap_init+0x46c>
    if (PPN(pa) >= npage) {
ffffffffc0202652:	000cb603          	ld	a2,0(s9)
    return pa2page(PTE_ADDR(pte));
ffffffffc0202656:	078a                	slli	a5,a5,0x2
ffffffffc0202658:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc020265a:	14c7f863          	bleu	a2,a5,ffffffffc02027aa <swap_init+0x434>
    return &pages[PPN(pa) - nbase];
ffffffffc020265e:	000db703          	ld	a4,0(s11)
ffffffffc0202662:	000c3603          	ld	a2,0(s8)
ffffffffc0202666:	00083583          	ld	a1,0(a6)
ffffffffc020266a:	8f99                	sub	a5,a5,a4
ffffffffc020266c:	079a                	slli	a5,a5,0x6
ffffffffc020266e:	e43a                	sd	a4,8(sp)
ffffffffc0202670:	97b2                	add	a5,a5,a2
ffffffffc0202672:	14f59863          	bne	a1,a5,ffffffffc02027c2 <swap_init+0x44c>
ffffffffc0202676:	6785                	lui	a5,0x1
ffffffffc0202678:	9d3e                	add	s10,s10,a5
     for (i= 0;i<CHECK_VALID_PHY_PAGE_NUM;i++) {
ffffffffc020267a:	6795                	lui	a5,0x5
ffffffffc020267c:	06a1                	addi	a3,a3,8
ffffffffc020267e:	0821                	addi	a6,a6,8
ffffffffc0202680:	fafd16e3          	bne	s10,a5,ffffffffc020262c <swap_init+0x2b6>
         assert((*check_ptep[i] & PTE_V));          
     }
     cprintf("set up init env for check_swap over!\n");
ffffffffc0202684:	00004517          	auipc	a0,0x4
ffffffffc0202688:	ddc50513          	addi	a0,a0,-548 # ffffffffc0206460 <commands+0x1470>
ffffffffc020268c:	a45fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    int ret = sm->check_swap();
ffffffffc0202690:	00013797          	auipc	a5,0x13
ffffffffc0202694:	e0878793          	addi	a5,a5,-504 # ffffffffc0215498 <sm>
ffffffffc0202698:	639c                	ld	a5,0(a5)
ffffffffc020269a:	7f9c                	ld	a5,56(a5)
ffffffffc020269c:	9782                	jalr	a5
     // now access the virt pages to test  page relpacement algorithm 
     ret=check_content_access();
     assert(ret==0);
ffffffffc020269e:	40051663          	bnez	a0,ffffffffc0202aaa <swap_init+0x734>

     nr_free = nr_free_store;
ffffffffc02026a2:	77a2                	ld	a5,40(sp)
ffffffffc02026a4:	00013717          	auipc	a4,0x13
ffffffffc02026a8:	f4f72223          	sw	a5,-188(a4) # ffffffffc02155e8 <free_area+0x10>
     free_list = free_list_store;
ffffffffc02026ac:	67e2                	ld	a5,24(sp)
ffffffffc02026ae:	00013717          	auipc	a4,0x13
ffffffffc02026b2:	f2f73523          	sd	a5,-214(a4) # ffffffffc02155d8 <free_area>
ffffffffc02026b6:	7782                	ld	a5,32(sp)
ffffffffc02026b8:	00013717          	auipc	a4,0x13
ffffffffc02026bc:	f2f73423          	sd	a5,-216(a4) # ffffffffc02155e0 <free_area+0x8>

     //restore kernel mem env
     for (i=0;i<CHECK_VALID_PHY_PAGE_NUM;i++) {
         free_pages(check_rp[i],1);
ffffffffc02026c0:	0009b503          	ld	a0,0(s3)
ffffffffc02026c4:	4585                	li	a1,1
ffffffffc02026c6:	09a1                	addi	s3,s3,8
ffffffffc02026c8:	d7afe0ef          	jal	ra,ffffffffc0200c42 <free_pages>
     for (i=0;i<CHECK_VALID_PHY_PAGE_NUM;i++) {
ffffffffc02026cc:	ff499ae3          	bne	s3,s4,ffffffffc02026c0 <swap_init+0x34a>
     } 

     //free_page(pte2page(*temp_ptep));
     
     mm_destroy(mm);
ffffffffc02026d0:	855e                	mv	a0,s7
ffffffffc02026d2:	e28ff0ef          	jal	ra,ffffffffc0201cfa <mm_destroy>

     pde_t *pd1=pgdir,*pd0=page2kva(pde2page(boot_pgdir[0]));
ffffffffc02026d6:	00013797          	auipc	a5,0x13
ffffffffc02026da:	daa78793          	addi	a5,a5,-598 # ffffffffc0215480 <boot_pgdir>
ffffffffc02026de:	639c                	ld	a5,0(a5)
    if (PPN(pa) >= npage) {
ffffffffc02026e0:	000cb703          	ld	a4,0(s9)
    return pa2page(PDE_ADDR(pde));
ffffffffc02026e4:	6394                	ld	a3,0(a5)
ffffffffc02026e6:	068a                	slli	a3,a3,0x2
ffffffffc02026e8:	82b1                	srli	a3,a3,0xc
    if (PPN(pa) >= npage) {
ffffffffc02026ea:	0ce6f063          	bleu	a4,a3,ffffffffc02027aa <swap_init+0x434>
    return &pages[PPN(pa) - nbase];
ffffffffc02026ee:	67a2                	ld	a5,8(sp)
ffffffffc02026f0:	000c3503          	ld	a0,0(s8)
ffffffffc02026f4:	8e9d                	sub	a3,a3,a5
ffffffffc02026f6:	069a                	slli	a3,a3,0x6
    return page - pages + nbase;
ffffffffc02026f8:	8699                	srai	a3,a3,0x6
ffffffffc02026fa:	96be                	add	a3,a3,a5
    return KADDR(page2pa(page));
ffffffffc02026fc:	57fd                	li	a5,-1
ffffffffc02026fe:	83b1                	srli	a5,a5,0xc
ffffffffc0202700:	8ff5                	and	a5,a5,a3
    return page2ppn(page) << PGSHIFT;
ffffffffc0202702:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc0202704:	2ee7f763          	bleu	a4,a5,ffffffffc02029f2 <swap_init+0x67c>
     free_page(pde2page(pd0[0]));
ffffffffc0202708:	00013797          	auipc	a5,0x13
ffffffffc020270c:	dd878793          	addi	a5,a5,-552 # ffffffffc02154e0 <va_pa_offset>
ffffffffc0202710:	639c                	ld	a5,0(a5)
ffffffffc0202712:	96be                	add	a3,a3,a5
    return pa2page(PDE_ADDR(pde));
ffffffffc0202714:	629c                	ld	a5,0(a3)
ffffffffc0202716:	078a                	slli	a5,a5,0x2
ffffffffc0202718:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc020271a:	08e7f863          	bleu	a4,a5,ffffffffc02027aa <swap_init+0x434>
    return &pages[PPN(pa) - nbase];
ffffffffc020271e:	69a2                	ld	s3,8(sp)
ffffffffc0202720:	4585                	li	a1,1
ffffffffc0202722:	413787b3          	sub	a5,a5,s3
ffffffffc0202726:	079a                	slli	a5,a5,0x6
ffffffffc0202728:	953e                	add	a0,a0,a5
ffffffffc020272a:	d18fe0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    return pa2page(PDE_ADDR(pde));
ffffffffc020272e:	000b3783          	ld	a5,0(s6)
    if (PPN(pa) >= npage) {
ffffffffc0202732:	000cb703          	ld	a4,0(s9)
    return pa2page(PDE_ADDR(pde));
ffffffffc0202736:	078a                	slli	a5,a5,0x2
ffffffffc0202738:	83b1                	srli	a5,a5,0xc
    if (PPN(pa) >= npage) {
ffffffffc020273a:	06e7f863          	bleu	a4,a5,ffffffffc02027aa <swap_init+0x434>
    return &pages[PPN(pa) - nbase];
ffffffffc020273e:	000c3503          	ld	a0,0(s8)
ffffffffc0202742:	413787b3          	sub	a5,a5,s3
ffffffffc0202746:	079a                	slli	a5,a5,0x6
     free_page(pde2page(pd1[0]));
ffffffffc0202748:	4585                	li	a1,1
ffffffffc020274a:	953e                	add	a0,a0,a5
ffffffffc020274c:	cf6fe0ef          	jal	ra,ffffffffc0200c42 <free_pages>
     pgdir[0] = 0;
ffffffffc0202750:	000b3023          	sd	zero,0(s6)
  asm volatile("sfence.vma");
ffffffffc0202754:	12000073          	sfence.vma
    return listelm->next;
ffffffffc0202758:	641c                	ld	a5,8(s0)
     flush_tlb();

     le = &free_list;
     while ((le = list_next(le)) != &free_list) {
ffffffffc020275a:	00878963          	beq	a5,s0,ffffffffc020276c <swap_init+0x3f6>
         struct Page *p = le2page(le, page_link);
         count --, total -= p->property;
ffffffffc020275e:	ff87a703          	lw	a4,-8(a5)
ffffffffc0202762:	679c                	ld	a5,8(a5)
ffffffffc0202764:	397d                	addiw	s2,s2,-1
ffffffffc0202766:	9c99                	subw	s1,s1,a4
     while ((le = list_next(le)) != &free_list) {
ffffffffc0202768:	fe879be3          	bne	a5,s0,ffffffffc020275e <swap_init+0x3e8>
     }
     assert(count==0);
ffffffffc020276c:	28091f63          	bnez	s2,ffffffffc0202a0a <swap_init+0x694>
     assert(total==0);
ffffffffc0202770:	2a049d63          	bnez	s1,ffffffffc0202a2a <swap_init+0x6b4>

     cprintf("check_swap() succeeded!\n");
ffffffffc0202774:	00004517          	auipc	a0,0x4
ffffffffc0202778:	d3c50513          	addi	a0,a0,-708 # ffffffffc02064b0 <commands+0x14c0>
ffffffffc020277c:	955fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
ffffffffc0202780:	b199                	j	ffffffffc02023c6 <swap_init+0x50>
     int ret, count = 0, total = 0, i;
ffffffffc0202782:	4481                	li	s1,0
ffffffffc0202784:	4901                	li	s2,0
     while ((le = list_next(le)) != &free_list) {
ffffffffc0202786:	4981                	li	s3,0
ffffffffc0202788:	b96d                	j	ffffffffc0202442 <swap_init+0xcc>
        assert(PageProperty(p));
ffffffffc020278a:	00004697          	auipc	a3,0x4
ffffffffc020278e:	ad668693          	addi	a3,a3,-1322 # ffffffffc0206260 <commands+0x1270>
ffffffffc0202792:	00003617          	auipc	a2,0x3
ffffffffc0202796:	1f660613          	addi	a2,a2,502 # ffffffffc0205988 <commands+0x998>
ffffffffc020279a:	0bd00593          	li	a1,189
ffffffffc020279e:	00004517          	auipc	a0,0x4
ffffffffc02027a2:	a9a50513          	addi	a0,a0,-1382 # ffffffffc0206238 <commands+0x1248>
ffffffffc02027a6:	a31fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
        panic("pa2page called with invalid pa");
ffffffffc02027aa:	00003617          	auipc	a2,0x3
ffffffffc02027ae:	0be60613          	addi	a2,a2,190 # ffffffffc0205868 <commands+0x878>
ffffffffc02027b2:	06200593          	li	a1,98
ffffffffc02027b6:	00003517          	auipc	a0,0x3
ffffffffc02027ba:	0d250513          	addi	a0,a0,210 # ffffffffc0205888 <commands+0x898>
ffffffffc02027be:	a19fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
         assert(pte2page(*check_ptep[i]) == check_rp[i]);
ffffffffc02027c2:	00004697          	auipc	a3,0x4
ffffffffc02027c6:	c7668693          	addi	a3,a3,-906 # ffffffffc0206438 <commands+0x1448>
ffffffffc02027ca:	00003617          	auipc	a2,0x3
ffffffffc02027ce:	1be60613          	addi	a2,a2,446 # ffffffffc0205988 <commands+0x998>
ffffffffc02027d2:	0fd00593          	li	a1,253
ffffffffc02027d6:	00004517          	auipc	a0,0x4
ffffffffc02027da:	a6250513          	addi	a0,a0,-1438 # ffffffffc0206238 <commands+0x1248>
ffffffffc02027de:	9f9fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
        panic("pte2page called with invalid pte");
ffffffffc02027e2:	00003617          	auipc	a2,0x3
ffffffffc02027e6:	27e60613          	addi	a2,a2,638 # ffffffffc0205a60 <commands+0xa70>
ffffffffc02027ea:	07400593          	li	a1,116
ffffffffc02027ee:	00003517          	auipc	a0,0x3
ffffffffc02027f2:	09a50513          	addi	a0,a0,154 # ffffffffc0205888 <commands+0x898>
ffffffffc02027f6:	9e1fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
          assert(!PageProperty(check_rp[i]));
ffffffffc02027fa:	00004697          	auipc	a3,0x4
ffffffffc02027fe:	b6668693          	addi	a3,a3,-1178 # ffffffffc0206360 <commands+0x1370>
ffffffffc0202802:	00003617          	auipc	a2,0x3
ffffffffc0202806:	18660613          	addi	a2,a2,390 # ffffffffc0205988 <commands+0x998>
ffffffffc020280a:	0de00593          	li	a1,222
ffffffffc020280e:	00004517          	auipc	a0,0x4
ffffffffc0202812:	a2a50513          	addi	a0,a0,-1494 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202816:	9c1fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
          assert(check_rp[i] != NULL );
ffffffffc020281a:	00004697          	auipc	a3,0x4
ffffffffc020281e:	b2e68693          	addi	a3,a3,-1234 # ffffffffc0206348 <commands+0x1358>
ffffffffc0202822:	00003617          	auipc	a2,0x3
ffffffffc0202826:	16660613          	addi	a2,a2,358 # ffffffffc0205988 <commands+0x998>
ffffffffc020282a:	0dd00593          	li	a1,221
ffffffffc020282e:	00004517          	auipc	a0,0x4
ffffffffc0202832:	a0a50513          	addi	a0,a0,-1526 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202836:	9a1fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
         assert(check_ptep[i] != NULL);
ffffffffc020283a:	00004697          	auipc	a3,0x4
ffffffffc020283e:	be668693          	addi	a3,a3,-1050 # ffffffffc0206420 <commands+0x1430>
ffffffffc0202842:	00003617          	auipc	a2,0x3
ffffffffc0202846:	14660613          	addi	a2,a2,326 # ffffffffc0205988 <commands+0x998>
ffffffffc020284a:	0fc00593          	li	a1,252
ffffffffc020284e:	00004517          	auipc	a0,0x4
ffffffffc0202852:	9ea50513          	addi	a0,a0,-1558 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202856:	981fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
        panic("bad max_swap_offset %08x.\n", max_swap_offset);
ffffffffc020285a:	00004617          	auipc	a2,0x4
ffffffffc020285e:	9be60613          	addi	a2,a2,-1602 # ffffffffc0206218 <commands+0x1228>
ffffffffc0202862:	02a00593          	li	a1,42
ffffffffc0202866:	00004517          	auipc	a0,0x4
ffffffffc020286a:	9d250513          	addi	a0,a0,-1582 # ffffffffc0206238 <commands+0x1248>
ffffffffc020286e:	969fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgfault_num==2);
ffffffffc0202872:	00004697          	auipc	a3,0x4
ffffffffc0202876:	b6e68693          	addi	a3,a3,-1170 # ffffffffc02063e0 <commands+0x13f0>
ffffffffc020287a:	00003617          	auipc	a2,0x3
ffffffffc020287e:	10e60613          	addi	a2,a2,270 # ffffffffc0205988 <commands+0x998>
ffffffffc0202882:	09800593          	li	a1,152
ffffffffc0202886:	00004517          	auipc	a0,0x4
ffffffffc020288a:	9b250513          	addi	a0,a0,-1614 # ffffffffc0206238 <commands+0x1248>
ffffffffc020288e:	949fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgfault_num==2);
ffffffffc0202892:	00004697          	auipc	a3,0x4
ffffffffc0202896:	b4e68693          	addi	a3,a3,-1202 # ffffffffc02063e0 <commands+0x13f0>
ffffffffc020289a:	00003617          	auipc	a2,0x3
ffffffffc020289e:	0ee60613          	addi	a2,a2,238 # ffffffffc0205988 <commands+0x998>
ffffffffc02028a2:	09a00593          	li	a1,154
ffffffffc02028a6:	00004517          	auipc	a0,0x4
ffffffffc02028aa:	99250513          	addi	a0,a0,-1646 # ffffffffc0206238 <commands+0x1248>
ffffffffc02028ae:	929fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgfault_num==3);
ffffffffc02028b2:	00004697          	auipc	a3,0x4
ffffffffc02028b6:	b3e68693          	addi	a3,a3,-1218 # ffffffffc02063f0 <commands+0x1400>
ffffffffc02028ba:	00003617          	auipc	a2,0x3
ffffffffc02028be:	0ce60613          	addi	a2,a2,206 # ffffffffc0205988 <commands+0x998>
ffffffffc02028c2:	09c00593          	li	a1,156
ffffffffc02028c6:	00004517          	auipc	a0,0x4
ffffffffc02028ca:	97250513          	addi	a0,a0,-1678 # ffffffffc0206238 <commands+0x1248>
ffffffffc02028ce:	909fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgfault_num==3);
ffffffffc02028d2:	00004697          	auipc	a3,0x4
ffffffffc02028d6:	b1e68693          	addi	a3,a3,-1250 # ffffffffc02063f0 <commands+0x1400>
ffffffffc02028da:	00003617          	auipc	a2,0x3
ffffffffc02028de:	0ae60613          	addi	a2,a2,174 # ffffffffc0205988 <commands+0x998>
ffffffffc02028e2:	09e00593          	li	a1,158
ffffffffc02028e6:	00004517          	auipc	a0,0x4
ffffffffc02028ea:	95250513          	addi	a0,a0,-1710 # ffffffffc0206238 <commands+0x1248>
ffffffffc02028ee:	8e9fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgfault_num==1);
ffffffffc02028f2:	00004697          	auipc	a3,0x4
ffffffffc02028f6:	ade68693          	addi	a3,a3,-1314 # ffffffffc02063d0 <commands+0x13e0>
ffffffffc02028fa:	00003617          	auipc	a2,0x3
ffffffffc02028fe:	08e60613          	addi	a2,a2,142 # ffffffffc0205988 <commands+0x998>
ffffffffc0202902:	09400593          	li	a1,148
ffffffffc0202906:	00004517          	auipc	a0,0x4
ffffffffc020290a:	93250513          	addi	a0,a0,-1742 # ffffffffc0206238 <commands+0x1248>
ffffffffc020290e:	8c9fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgfault_num==1);
ffffffffc0202912:	00004697          	auipc	a3,0x4
ffffffffc0202916:	abe68693          	addi	a3,a3,-1346 # ffffffffc02063d0 <commands+0x13e0>
ffffffffc020291a:	00003617          	auipc	a2,0x3
ffffffffc020291e:	06e60613          	addi	a2,a2,110 # ffffffffc0205988 <commands+0x998>
ffffffffc0202922:	09600593          	li	a1,150
ffffffffc0202926:	00004517          	auipc	a0,0x4
ffffffffc020292a:	91250513          	addi	a0,a0,-1774 # ffffffffc0206238 <commands+0x1248>
ffffffffc020292e:	8a9fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgfault_num==4);
ffffffffc0202932:	00004697          	auipc	a3,0x4
ffffffffc0202936:	ace68693          	addi	a3,a3,-1330 # ffffffffc0206400 <commands+0x1410>
ffffffffc020293a:	00003617          	auipc	a2,0x3
ffffffffc020293e:	04e60613          	addi	a2,a2,78 # ffffffffc0205988 <commands+0x998>
ffffffffc0202942:	0a000593          	li	a1,160
ffffffffc0202946:	00004517          	auipc	a0,0x4
ffffffffc020294a:	8f250513          	addi	a0,a0,-1806 # ffffffffc0206238 <commands+0x1248>
ffffffffc020294e:	889fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgfault_num==4);
ffffffffc0202952:	00004697          	auipc	a3,0x4
ffffffffc0202956:	aae68693          	addi	a3,a3,-1362 # ffffffffc0206400 <commands+0x1410>
ffffffffc020295a:	00003617          	auipc	a2,0x3
ffffffffc020295e:	02e60613          	addi	a2,a2,46 # ffffffffc0205988 <commands+0x998>
ffffffffc0202962:	0a200593          	li	a1,162
ffffffffc0202966:	00004517          	auipc	a0,0x4
ffffffffc020296a:	8d250513          	addi	a0,a0,-1838 # ffffffffc0206238 <commands+0x1248>
ffffffffc020296e:	869fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(pgdir[0] == 0);
ffffffffc0202972:	00003697          	auipc	a3,0x3
ffffffffc0202976:	7a668693          	addi	a3,a3,1958 # ffffffffc0206118 <commands+0x1128>
ffffffffc020297a:	00003617          	auipc	a2,0x3
ffffffffc020297e:	00e60613          	addi	a2,a2,14 # ffffffffc0205988 <commands+0x998>
ffffffffc0202982:	0cd00593          	li	a1,205
ffffffffc0202986:	00004517          	auipc	a0,0x4
ffffffffc020298a:	8b250513          	addi	a0,a0,-1870 # ffffffffc0206238 <commands+0x1248>
ffffffffc020298e:	849fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(vma != NULL);
ffffffffc0202992:	00004697          	auipc	a3,0x4
ffffffffc0202996:	82668693          	addi	a3,a3,-2010 # ffffffffc02061b8 <commands+0x11c8>
ffffffffc020299a:	00003617          	auipc	a2,0x3
ffffffffc020299e:	fee60613          	addi	a2,a2,-18 # ffffffffc0205988 <commands+0x998>
ffffffffc02029a2:	0d000593          	li	a1,208
ffffffffc02029a6:	00004517          	auipc	a0,0x4
ffffffffc02029aa:	89250513          	addi	a0,a0,-1902 # ffffffffc0206238 <commands+0x1248>
ffffffffc02029ae:	829fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(temp_ptep!= NULL);
ffffffffc02029b2:	00004697          	auipc	a3,0x4
ffffffffc02029b6:	95668693          	addi	a3,a3,-1706 # ffffffffc0206308 <commands+0x1318>
ffffffffc02029ba:	00003617          	auipc	a2,0x3
ffffffffc02029be:	fce60613          	addi	a2,a2,-50 # ffffffffc0205988 <commands+0x998>
ffffffffc02029c2:	0d800593          	li	a1,216
ffffffffc02029c6:	00004517          	auipc	a0,0x4
ffffffffc02029ca:	87250513          	addi	a0,a0,-1934 # ffffffffc0206238 <commands+0x1248>
ffffffffc02029ce:	809fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert( nr_free == 0);         
ffffffffc02029d2:	00004697          	auipc	a3,0x4
ffffffffc02029d6:	a3e68693          	addi	a3,a3,-1474 # ffffffffc0206410 <commands+0x1420>
ffffffffc02029da:	00003617          	auipc	a2,0x3
ffffffffc02029de:	fae60613          	addi	a2,a2,-82 # ffffffffc0205988 <commands+0x998>
ffffffffc02029e2:	0f400593          	li	a1,244
ffffffffc02029e6:	00004517          	auipc	a0,0x4
ffffffffc02029ea:	85250513          	addi	a0,a0,-1966 # ffffffffc0206238 <commands+0x1248>
ffffffffc02029ee:	fe8fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
    return KADDR(page2pa(page));
ffffffffc02029f2:	00003617          	auipc	a2,0x3
ffffffffc02029f6:	e3e60613          	addi	a2,a2,-450 # ffffffffc0205830 <commands+0x840>
ffffffffc02029fa:	06900593          	li	a1,105
ffffffffc02029fe:	00003517          	auipc	a0,0x3
ffffffffc0202a02:	e8a50513          	addi	a0,a0,-374 # ffffffffc0205888 <commands+0x898>
ffffffffc0202a06:	fd0fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(count==0);
ffffffffc0202a0a:	00004697          	auipc	a3,0x4
ffffffffc0202a0e:	a8668693          	addi	a3,a3,-1402 # ffffffffc0206490 <commands+0x14a0>
ffffffffc0202a12:	00003617          	auipc	a2,0x3
ffffffffc0202a16:	f7660613          	addi	a2,a2,-138 # ffffffffc0205988 <commands+0x998>
ffffffffc0202a1a:	11c00593          	li	a1,284
ffffffffc0202a1e:	00004517          	auipc	a0,0x4
ffffffffc0202a22:	81a50513          	addi	a0,a0,-2022 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202a26:	fb0fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(total==0);
ffffffffc0202a2a:	00004697          	auipc	a3,0x4
ffffffffc0202a2e:	a7668693          	addi	a3,a3,-1418 # ffffffffc02064a0 <commands+0x14b0>
ffffffffc0202a32:	00003617          	auipc	a2,0x3
ffffffffc0202a36:	f5660613          	addi	a2,a2,-170 # ffffffffc0205988 <commands+0x998>
ffffffffc0202a3a:	11d00593          	li	a1,285
ffffffffc0202a3e:	00003517          	auipc	a0,0x3
ffffffffc0202a42:	7fa50513          	addi	a0,a0,2042 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202a46:	f90fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(nr_free==CHECK_VALID_PHY_PAGE_NUM);
ffffffffc0202a4a:	00004697          	auipc	a3,0x4
ffffffffc0202a4e:	93668693          	addi	a3,a3,-1738 # ffffffffc0206380 <commands+0x1390>
ffffffffc0202a52:	00003617          	auipc	a2,0x3
ffffffffc0202a56:	f3660613          	addi	a2,a2,-202 # ffffffffc0205988 <commands+0x998>
ffffffffc0202a5a:	0eb00593          	li	a1,235
ffffffffc0202a5e:	00003517          	auipc	a0,0x3
ffffffffc0202a62:	7da50513          	addi	a0,a0,2010 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202a66:	f70fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(mm != NULL);
ffffffffc0202a6a:	00003697          	auipc	a3,0x3
ffffffffc0202a6e:	52668693          	addi	a3,a3,1318 # ffffffffc0205f90 <commands+0xfa0>
ffffffffc0202a72:	00003617          	auipc	a2,0x3
ffffffffc0202a76:	f1660613          	addi	a2,a2,-234 # ffffffffc0205988 <commands+0x998>
ffffffffc0202a7a:	0c500593          	li	a1,197
ffffffffc0202a7e:	00003517          	auipc	a0,0x3
ffffffffc0202a82:	7ba50513          	addi	a0,a0,1978 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202a86:	f50fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(check_mm_struct == NULL);
ffffffffc0202a8a:	00004697          	auipc	a3,0x4
ffffffffc0202a8e:	82e68693          	addi	a3,a3,-2002 # ffffffffc02062b8 <commands+0x12c8>
ffffffffc0202a92:	00003617          	auipc	a2,0x3
ffffffffc0202a96:	ef660613          	addi	a2,a2,-266 # ffffffffc0205988 <commands+0x998>
ffffffffc0202a9a:	0c800593          	li	a1,200
ffffffffc0202a9e:	00003517          	auipc	a0,0x3
ffffffffc0202aa2:	79a50513          	addi	a0,a0,1946 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202aa6:	f30fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(ret==0);
ffffffffc0202aaa:	00004697          	auipc	a3,0x4
ffffffffc0202aae:	9de68693          	addi	a3,a3,-1570 # ffffffffc0206488 <commands+0x1498>
ffffffffc0202ab2:	00003617          	auipc	a2,0x3
ffffffffc0202ab6:	ed660613          	addi	a2,a2,-298 # ffffffffc0205988 <commands+0x998>
ffffffffc0202aba:	10300593          	li	a1,259
ffffffffc0202abe:	00003517          	auipc	a0,0x3
ffffffffc0202ac2:	77a50513          	addi	a0,a0,1914 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202ac6:	f10fd0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(total == nr_free_pages());
ffffffffc0202aca:	00003697          	auipc	a3,0x3
ffffffffc0202ace:	7a668693          	addi	a3,a3,1958 # ffffffffc0206270 <commands+0x1280>
ffffffffc0202ad2:	00003617          	auipc	a2,0x3
ffffffffc0202ad6:	eb660613          	addi	a2,a2,-330 # ffffffffc0205988 <commands+0x998>
ffffffffc0202ada:	0c000593          	li	a1,192
ffffffffc0202ade:	00003517          	auipc	a0,0x3
ffffffffc0202ae2:	75a50513          	addi	a0,a0,1882 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202ae6:	ef0fd0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0202aea <swap_init_mm>:
     return sm->init_mm(mm);
ffffffffc0202aea:	00013797          	auipc	a5,0x13
ffffffffc0202aee:	9ae78793          	addi	a5,a5,-1618 # ffffffffc0215498 <sm>
ffffffffc0202af2:	639c                	ld	a5,0(a5)
ffffffffc0202af4:	0107b303          	ld	t1,16(a5)
ffffffffc0202af8:	8302                	jr	t1

ffffffffc0202afa <swap_map_swappable>:
     return sm->map_swappable(mm, addr, page, swap_in);
ffffffffc0202afa:	00013797          	auipc	a5,0x13
ffffffffc0202afe:	99e78793          	addi	a5,a5,-1634 # ffffffffc0215498 <sm>
ffffffffc0202b02:	639c                	ld	a5,0(a5)
ffffffffc0202b04:	0207b303          	ld	t1,32(a5)
ffffffffc0202b08:	8302                	jr	t1

ffffffffc0202b0a <swap_out>:
{
ffffffffc0202b0a:	711d                	addi	sp,sp,-96
ffffffffc0202b0c:	ec86                	sd	ra,88(sp)
ffffffffc0202b0e:	e8a2                	sd	s0,80(sp)
ffffffffc0202b10:	e4a6                	sd	s1,72(sp)
ffffffffc0202b12:	e0ca                	sd	s2,64(sp)
ffffffffc0202b14:	fc4e                	sd	s3,56(sp)
ffffffffc0202b16:	f852                	sd	s4,48(sp)
ffffffffc0202b18:	f456                	sd	s5,40(sp)
ffffffffc0202b1a:	f05a                	sd	s6,32(sp)
ffffffffc0202b1c:	ec5e                	sd	s7,24(sp)
ffffffffc0202b1e:	e862                	sd	s8,16(sp)
     for (i = 0; i != n; ++ i)
ffffffffc0202b20:	cde9                	beqz	a1,ffffffffc0202bfa <swap_out+0xf0>
ffffffffc0202b22:	8ab2                	mv	s5,a2
ffffffffc0202b24:	892a                	mv	s2,a0
ffffffffc0202b26:	8a2e                	mv	s4,a1
ffffffffc0202b28:	4401                	li	s0,0
ffffffffc0202b2a:	00013997          	auipc	s3,0x13
ffffffffc0202b2e:	96e98993          	addi	s3,s3,-1682 # ffffffffc0215498 <sm>
                    cprintf("swap_out: i %d, store page in vaddr 0x%x to disk swap entry %d\n", i, v, page->pra_vaddr/PGSIZE+1);
ffffffffc0202b32:	00004b17          	auipc	s6,0x4
ffffffffc0202b36:	9feb0b13          	addi	s6,s6,-1538 # ffffffffc0206530 <commands+0x1540>
                    cprintf("SWAP: failed to save\n");
ffffffffc0202b3a:	00004b97          	auipc	s7,0x4
ffffffffc0202b3e:	9deb8b93          	addi	s7,s7,-1570 # ffffffffc0206518 <commands+0x1528>
ffffffffc0202b42:	a825                	j	ffffffffc0202b7a <swap_out+0x70>
                    cprintf("swap_out: i %d, store page in vaddr 0x%x to disk swap entry %d\n", i, v, page->pra_vaddr/PGSIZE+1);
ffffffffc0202b44:	67a2                	ld	a5,8(sp)
ffffffffc0202b46:	8626                	mv	a2,s1
ffffffffc0202b48:	85a2                	mv	a1,s0
ffffffffc0202b4a:	7f94                	ld	a3,56(a5)
ffffffffc0202b4c:	855a                	mv	a0,s6
     for (i = 0; i != n; ++ i)
ffffffffc0202b4e:	2405                	addiw	s0,s0,1
                    cprintf("swap_out: i %d, store page in vaddr 0x%x to disk swap entry %d\n", i, v, page->pra_vaddr/PGSIZE+1);
ffffffffc0202b50:	82b1                	srli	a3,a3,0xc
ffffffffc0202b52:	0685                	addi	a3,a3,1
ffffffffc0202b54:	d7cfd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
                    *ptep = (page->pra_vaddr/PGSIZE+1)<<8;
ffffffffc0202b58:	6522                	ld	a0,8(sp)
                    free_page(page);
ffffffffc0202b5a:	4585                	li	a1,1
                    *ptep = (page->pra_vaddr/PGSIZE+1)<<8;
ffffffffc0202b5c:	7d1c                	ld	a5,56(a0)
ffffffffc0202b5e:	83b1                	srli	a5,a5,0xc
ffffffffc0202b60:	0785                	addi	a5,a5,1
ffffffffc0202b62:	07a2                	slli	a5,a5,0x8
ffffffffc0202b64:	00fc3023          	sd	a5,0(s8)
                    free_page(page);
ffffffffc0202b68:	8dafe0ef          	jal	ra,ffffffffc0200c42 <free_pages>
          tlb_invalidate(mm->pgdir, v);
ffffffffc0202b6c:	01893503          	ld	a0,24(s2)
ffffffffc0202b70:	85a6                	mv	a1,s1
ffffffffc0202b72:	f47fe0ef          	jal	ra,ffffffffc0201ab8 <tlb_invalidate>
     for (i = 0; i != n; ++ i)
ffffffffc0202b76:	048a0d63          	beq	s4,s0,ffffffffc0202bd0 <swap_out+0xc6>
          int r = sm->swap_out_victim(mm, &page, in_tick);
ffffffffc0202b7a:	0009b783          	ld	a5,0(s3)
ffffffffc0202b7e:	8656                	mv	a2,s5
ffffffffc0202b80:	002c                	addi	a1,sp,8
ffffffffc0202b82:	7b9c                	ld	a5,48(a5)
ffffffffc0202b84:	854a                	mv	a0,s2
ffffffffc0202b86:	9782                	jalr	a5
          if (r != 0) {
ffffffffc0202b88:	e12d                	bnez	a0,ffffffffc0202bea <swap_out+0xe0>
          v=page->pra_vaddr; 
ffffffffc0202b8a:	67a2                	ld	a5,8(sp)
          pte_t *ptep = get_pte(mm->pgdir, v, 0);
ffffffffc0202b8c:	01893503          	ld	a0,24(s2)
ffffffffc0202b90:	4601                	li	a2,0
          v=page->pra_vaddr; 
ffffffffc0202b92:	7f84                	ld	s1,56(a5)
          pte_t *ptep = get_pte(mm->pgdir, v, 0);
ffffffffc0202b94:	85a6                	mv	a1,s1
ffffffffc0202b96:	932fe0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
          assert((*ptep & PTE_V) != 0);
ffffffffc0202b9a:	611c                	ld	a5,0(a0)
          pte_t *ptep = get_pte(mm->pgdir, v, 0);
ffffffffc0202b9c:	8c2a                	mv	s8,a0
          assert((*ptep & PTE_V) != 0);
ffffffffc0202b9e:	8b85                	andi	a5,a5,1
ffffffffc0202ba0:	cfb9                	beqz	a5,ffffffffc0202bfe <swap_out+0xf4>
          if (swapfs_write( (page->pra_vaddr/PGSIZE+1)<<8, page) != 0) {
ffffffffc0202ba2:	65a2                	ld	a1,8(sp)
ffffffffc0202ba4:	7d9c                	ld	a5,56(a1)
ffffffffc0202ba6:	83b1                	srli	a5,a5,0xc
ffffffffc0202ba8:	00178513          	addi	a0,a5,1
ffffffffc0202bac:	0522                	slli	a0,a0,0x8
ffffffffc0202bae:	57e010ef          	jal	ra,ffffffffc020412c <swapfs_write>
ffffffffc0202bb2:	d949                	beqz	a0,ffffffffc0202b44 <swap_out+0x3a>
                    cprintf("SWAP: failed to save\n");
ffffffffc0202bb4:	855e                	mv	a0,s7
ffffffffc0202bb6:	d1afd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
                    sm->map_swappable(mm, v, page, 0);
ffffffffc0202bba:	0009b783          	ld	a5,0(s3)
ffffffffc0202bbe:	6622                	ld	a2,8(sp)
ffffffffc0202bc0:	4681                	li	a3,0
ffffffffc0202bc2:	739c                	ld	a5,32(a5)
ffffffffc0202bc4:	85a6                	mv	a1,s1
ffffffffc0202bc6:	854a                	mv	a0,s2
     for (i = 0; i != n; ++ i)
ffffffffc0202bc8:	2405                	addiw	s0,s0,1
                    sm->map_swappable(mm, v, page, 0);
ffffffffc0202bca:	9782                	jalr	a5
     for (i = 0; i != n; ++ i)
ffffffffc0202bcc:	fa8a17e3          	bne	s4,s0,ffffffffc0202b7a <swap_out+0x70>
}
ffffffffc0202bd0:	8522                	mv	a0,s0
ffffffffc0202bd2:	60e6                	ld	ra,88(sp)
ffffffffc0202bd4:	6446                	ld	s0,80(sp)
ffffffffc0202bd6:	64a6                	ld	s1,72(sp)
ffffffffc0202bd8:	6906                	ld	s2,64(sp)
ffffffffc0202bda:	79e2                	ld	s3,56(sp)
ffffffffc0202bdc:	7a42                	ld	s4,48(sp)
ffffffffc0202bde:	7aa2                	ld	s5,40(sp)
ffffffffc0202be0:	7b02                	ld	s6,32(sp)
ffffffffc0202be2:	6be2                	ld	s7,24(sp)
ffffffffc0202be4:	6c42                	ld	s8,16(sp)
ffffffffc0202be6:	6125                	addi	sp,sp,96
ffffffffc0202be8:	8082                	ret
                    cprintf("i %d, swap_out: call swap_out_victim failed\n",i);
ffffffffc0202bea:	85a2                	mv	a1,s0
ffffffffc0202bec:	00004517          	auipc	a0,0x4
ffffffffc0202bf0:	8e450513          	addi	a0,a0,-1820 # ffffffffc02064d0 <commands+0x14e0>
ffffffffc0202bf4:	cdcfd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
                  break;
ffffffffc0202bf8:	bfe1                	j	ffffffffc0202bd0 <swap_out+0xc6>
     for (i = 0; i != n; ++ i)
ffffffffc0202bfa:	4401                	li	s0,0
ffffffffc0202bfc:	bfd1                	j	ffffffffc0202bd0 <swap_out+0xc6>
          assert((*ptep & PTE_V) != 0);
ffffffffc0202bfe:	00004697          	auipc	a3,0x4
ffffffffc0202c02:	90268693          	addi	a3,a3,-1790 # ffffffffc0206500 <commands+0x1510>
ffffffffc0202c06:	00003617          	auipc	a2,0x3
ffffffffc0202c0a:	d8260613          	addi	a2,a2,-638 # ffffffffc0205988 <commands+0x998>
ffffffffc0202c0e:	06900593          	li	a1,105
ffffffffc0202c12:	00003517          	auipc	a0,0x3
ffffffffc0202c16:	62650513          	addi	a0,a0,1574 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202c1a:	dbcfd0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0202c1e <swap_in>:
{
ffffffffc0202c1e:	7179                	addi	sp,sp,-48
ffffffffc0202c20:	e84a                	sd	s2,16(sp)
ffffffffc0202c22:	892a                	mv	s2,a0
     struct Page *result = alloc_page();
ffffffffc0202c24:	4505                	li	a0,1
{
ffffffffc0202c26:	ec26                	sd	s1,24(sp)
ffffffffc0202c28:	e44e                	sd	s3,8(sp)
ffffffffc0202c2a:	f406                	sd	ra,40(sp)
ffffffffc0202c2c:	f022                	sd	s0,32(sp)
ffffffffc0202c2e:	84ae                	mv	s1,a1
ffffffffc0202c30:	89b2                	mv	s3,a2
     struct Page *result = alloc_page();
ffffffffc0202c32:	f89fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
     assert(result!=NULL);
ffffffffc0202c36:	c129                	beqz	a0,ffffffffc0202c78 <swap_in+0x5a>
     pte_t *ptep = get_pte(mm->pgdir, addr, 0);
ffffffffc0202c38:	842a                	mv	s0,a0
ffffffffc0202c3a:	01893503          	ld	a0,24(s2)
ffffffffc0202c3e:	4601                	li	a2,0
ffffffffc0202c40:	85a6                	mv	a1,s1
ffffffffc0202c42:	886fe0ef          	jal	ra,ffffffffc0200cc8 <get_pte>
ffffffffc0202c46:	892a                	mv	s2,a0
     if ((r = swapfs_read((*ptep), result)) != 0)
ffffffffc0202c48:	6108                	ld	a0,0(a0)
ffffffffc0202c4a:	85a2                	mv	a1,s0
ffffffffc0202c4c:	448010ef          	jal	ra,ffffffffc0204094 <swapfs_read>
     cprintf("swap_in: load disk swap entry %d with swap_page in vadr 0x%x\n", (*ptep)>>8, addr);
ffffffffc0202c50:	00093583          	ld	a1,0(s2)
ffffffffc0202c54:	8626                	mv	a2,s1
ffffffffc0202c56:	00003517          	auipc	a0,0x3
ffffffffc0202c5a:	58250513          	addi	a0,a0,1410 # ffffffffc02061d8 <commands+0x11e8>
ffffffffc0202c5e:	81a1                	srli	a1,a1,0x8
ffffffffc0202c60:	c70fd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
}
ffffffffc0202c64:	70a2                	ld	ra,40(sp)
     *ptr_result=result;
ffffffffc0202c66:	0089b023          	sd	s0,0(s3)
}
ffffffffc0202c6a:	7402                	ld	s0,32(sp)
ffffffffc0202c6c:	64e2                	ld	s1,24(sp)
ffffffffc0202c6e:	6942                	ld	s2,16(sp)
ffffffffc0202c70:	69a2                	ld	s3,8(sp)
ffffffffc0202c72:	4501                	li	a0,0
ffffffffc0202c74:	6145                	addi	sp,sp,48
ffffffffc0202c76:	8082                	ret
     assert(result!=NULL);
ffffffffc0202c78:	00003697          	auipc	a3,0x3
ffffffffc0202c7c:	55068693          	addi	a3,a3,1360 # ffffffffc02061c8 <commands+0x11d8>
ffffffffc0202c80:	00003617          	auipc	a2,0x3
ffffffffc0202c84:	d0860613          	addi	a2,a2,-760 # ffffffffc0205988 <commands+0x998>
ffffffffc0202c88:	07f00593          	li	a1,127
ffffffffc0202c8c:	00003517          	auipc	a0,0x3
ffffffffc0202c90:	5ac50513          	addi	a0,a0,1452 # ffffffffc0206238 <commands+0x1248>
ffffffffc0202c94:	d42fd0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0202c98 <slob_free>:
static void slob_free(void *block, int size)
{
	slob_t *cur, *b = (slob_t *)block;
	unsigned long flags;

	if (!block)
ffffffffc0202c98:	c125                	beqz	a0,ffffffffc0202cf8 <slob_free+0x60>
		return;

	if (size)
ffffffffc0202c9a:	e1a5                	bnez	a1,ffffffffc0202cfa <slob_free+0x62>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0202c9c:	100027f3          	csrr	a5,sstatus
ffffffffc0202ca0:	8b89                	andi	a5,a5,2
    return 0;
ffffffffc0202ca2:	4581                	li	a1,0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0202ca4:	e3bd                	bnez	a5,ffffffffc0202d0a <slob_free+0x72>
		b->units = SLOB_UNITS(size);

	/* Find reinsertion point */
	spin_lock_irqsave(&slob_lock, flags);
	for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next)
ffffffffc0202ca6:	00007797          	auipc	a5,0x7
ffffffffc0202caa:	3aa78793          	addi	a5,a5,938 # ffffffffc020a050 <slobfree>
ffffffffc0202cae:	639c                	ld	a5,0(a5)
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc0202cb0:	6798                	ld	a4,8(a5)
	for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next)
ffffffffc0202cb2:	00a7fa63          	bleu	a0,a5,ffffffffc0202cc6 <slob_free+0x2e>
ffffffffc0202cb6:	00e56c63          	bltu	a0,a4,ffffffffc0202cce <slob_free+0x36>
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc0202cba:	00e7fa63          	bleu	a4,a5,ffffffffc0202cce <slob_free+0x36>
    return 0;
ffffffffc0202cbe:	87ba                	mv	a5,a4
ffffffffc0202cc0:	6798                	ld	a4,8(a5)
	for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next)
ffffffffc0202cc2:	fea7eae3          	bltu	a5,a0,ffffffffc0202cb6 <slob_free+0x1e>
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc0202cc6:	fee7ece3          	bltu	a5,a4,ffffffffc0202cbe <slob_free+0x26>
ffffffffc0202cca:	fee57ae3          	bleu	a4,a0,ffffffffc0202cbe <slob_free+0x26>
			break;

	if (b + b->units == cur->next) {
ffffffffc0202cce:	4110                	lw	a2,0(a0)
ffffffffc0202cd0:	00461693          	slli	a3,a2,0x4
ffffffffc0202cd4:	96aa                	add	a3,a3,a0
ffffffffc0202cd6:	08d70b63          	beq	a4,a3,ffffffffc0202d6c <slob_free+0xd4>
		b->units += cur->next->units;
		b->next = cur->next->next;
	} else
		b->next = cur->next;

	if (cur + cur->units == b) {
ffffffffc0202cda:	4394                	lw	a3,0(a5)
		b->next = cur->next;
ffffffffc0202cdc:	e518                	sd	a4,8(a0)
	if (cur + cur->units == b) {
ffffffffc0202cde:	00469713          	slli	a4,a3,0x4
ffffffffc0202ce2:	973e                	add	a4,a4,a5
ffffffffc0202ce4:	08e50f63          	beq	a0,a4,ffffffffc0202d82 <slob_free+0xea>
		cur->units += b->units;
		cur->next = b->next;
	} else
		cur->next = b;
ffffffffc0202ce8:	e788                	sd	a0,8(a5)

	slobfree = cur;
ffffffffc0202cea:	00007717          	auipc	a4,0x7
ffffffffc0202cee:	36f73323          	sd	a5,870(a4) # ffffffffc020a050 <slobfree>
    if (flag) {
ffffffffc0202cf2:	c199                	beqz	a1,ffffffffc0202cf8 <slob_free+0x60>
        intr_enable();
ffffffffc0202cf4:	8e1fd06f          	j	ffffffffc02005d4 <intr_enable>
ffffffffc0202cf8:	8082                	ret
		b->units = SLOB_UNITS(size);
ffffffffc0202cfa:	05bd                	addi	a1,a1,15
ffffffffc0202cfc:	8191                	srli	a1,a1,0x4
ffffffffc0202cfe:	c10c                	sw	a1,0(a0)
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0202d00:	100027f3          	csrr	a5,sstatus
ffffffffc0202d04:	8b89                	andi	a5,a5,2
    return 0;
ffffffffc0202d06:	4581                	li	a1,0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0202d08:	dfd9                	beqz	a5,ffffffffc0202ca6 <slob_free+0xe>
{
ffffffffc0202d0a:	1101                	addi	sp,sp,-32
ffffffffc0202d0c:	e42a                	sd	a0,8(sp)
ffffffffc0202d0e:	ec06                	sd	ra,24(sp)
        intr_disable();
ffffffffc0202d10:	8cbfd0ef          	jal	ra,ffffffffc02005da <intr_disable>
	for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next)
ffffffffc0202d14:	00007797          	auipc	a5,0x7
ffffffffc0202d18:	33c78793          	addi	a5,a5,828 # ffffffffc020a050 <slobfree>
ffffffffc0202d1c:	639c                	ld	a5,0(a5)
        return 1;
ffffffffc0202d1e:	6522                	ld	a0,8(sp)
ffffffffc0202d20:	4585                	li	a1,1
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc0202d22:	6798                	ld	a4,8(a5)
	for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next)
ffffffffc0202d24:	00a7fa63          	bleu	a0,a5,ffffffffc0202d38 <slob_free+0xa0>
ffffffffc0202d28:	00e56c63          	bltu	a0,a4,ffffffffc0202d40 <slob_free+0xa8>
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc0202d2c:	00e7fa63          	bleu	a4,a5,ffffffffc0202d40 <slob_free+0xa8>
    return 0;
ffffffffc0202d30:	87ba                	mv	a5,a4
ffffffffc0202d32:	6798                	ld	a4,8(a5)
	for (cur = slobfree; !(b > cur && b < cur->next); cur = cur->next)
ffffffffc0202d34:	fea7eae3          	bltu	a5,a0,ffffffffc0202d28 <slob_free+0x90>
		if (cur >= cur->next && (b > cur || b < cur->next))
ffffffffc0202d38:	fee7ece3          	bltu	a5,a4,ffffffffc0202d30 <slob_free+0x98>
ffffffffc0202d3c:	fee57ae3          	bleu	a4,a0,ffffffffc0202d30 <slob_free+0x98>
	if (b + b->units == cur->next) {
ffffffffc0202d40:	4110                	lw	a2,0(a0)
ffffffffc0202d42:	00461693          	slli	a3,a2,0x4
ffffffffc0202d46:	96aa                	add	a3,a3,a0
ffffffffc0202d48:	04d70763          	beq	a4,a3,ffffffffc0202d96 <slob_free+0xfe>
		b->next = cur->next;
ffffffffc0202d4c:	e518                	sd	a4,8(a0)
	if (cur + cur->units == b) {
ffffffffc0202d4e:	4394                	lw	a3,0(a5)
ffffffffc0202d50:	00469713          	slli	a4,a3,0x4
ffffffffc0202d54:	973e                	add	a4,a4,a5
ffffffffc0202d56:	04e50663          	beq	a0,a4,ffffffffc0202da2 <slob_free+0x10a>
		cur->next = b;
ffffffffc0202d5a:	e788                	sd	a0,8(a5)
	slobfree = cur;
ffffffffc0202d5c:	00007717          	auipc	a4,0x7
ffffffffc0202d60:	2ef73a23          	sd	a5,756(a4) # ffffffffc020a050 <slobfree>
    if (flag) {
ffffffffc0202d64:	e58d                	bnez	a1,ffffffffc0202d8e <slob_free+0xf6>

	spin_unlock_irqrestore(&slob_lock, flags);
}
ffffffffc0202d66:	60e2                	ld	ra,24(sp)
ffffffffc0202d68:	6105                	addi	sp,sp,32
ffffffffc0202d6a:	8082                	ret
		b->units += cur->next->units;
ffffffffc0202d6c:	4314                	lw	a3,0(a4)
		b->next = cur->next->next;
ffffffffc0202d6e:	6718                	ld	a4,8(a4)
		b->units += cur->next->units;
ffffffffc0202d70:	9e35                	addw	a2,a2,a3
ffffffffc0202d72:	c110                	sw	a2,0(a0)
	if (cur + cur->units == b) {
ffffffffc0202d74:	4394                	lw	a3,0(a5)
		b->next = cur->next->next;
ffffffffc0202d76:	e518                	sd	a4,8(a0)
	if (cur + cur->units == b) {
ffffffffc0202d78:	00469713          	slli	a4,a3,0x4
ffffffffc0202d7c:	973e                	add	a4,a4,a5
ffffffffc0202d7e:	f6e515e3          	bne	a0,a4,ffffffffc0202ce8 <slob_free+0x50>
		cur->units += b->units;
ffffffffc0202d82:	4118                	lw	a4,0(a0)
		cur->next = b->next;
ffffffffc0202d84:	6510                	ld	a2,8(a0)
		cur->units += b->units;
ffffffffc0202d86:	9eb9                	addw	a3,a3,a4
ffffffffc0202d88:	c394                	sw	a3,0(a5)
		cur->next = b->next;
ffffffffc0202d8a:	e790                	sd	a2,8(a5)
ffffffffc0202d8c:	bfb9                	j	ffffffffc0202cea <slob_free+0x52>
}
ffffffffc0202d8e:	60e2                	ld	ra,24(sp)
ffffffffc0202d90:	6105                	addi	sp,sp,32
        intr_enable();
ffffffffc0202d92:	843fd06f          	j	ffffffffc02005d4 <intr_enable>
		b->units += cur->next->units;
ffffffffc0202d96:	4314                	lw	a3,0(a4)
		b->next = cur->next->next;
ffffffffc0202d98:	6718                	ld	a4,8(a4)
		b->units += cur->next->units;
ffffffffc0202d9a:	9e35                	addw	a2,a2,a3
ffffffffc0202d9c:	c110                	sw	a2,0(a0)
		b->next = cur->next->next;
ffffffffc0202d9e:	e518                	sd	a4,8(a0)
ffffffffc0202da0:	b77d                	j	ffffffffc0202d4e <slob_free+0xb6>
		cur->units += b->units;
ffffffffc0202da2:	4118                	lw	a4,0(a0)
		cur->next = b->next;
ffffffffc0202da4:	6510                	ld	a2,8(a0)
		cur->units += b->units;
ffffffffc0202da6:	9eb9                	addw	a3,a3,a4
ffffffffc0202da8:	c394                	sw	a3,0(a5)
		cur->next = b->next;
ffffffffc0202daa:	e790                	sd	a2,8(a5)
ffffffffc0202dac:	bf45                	j	ffffffffc0202d5c <slob_free+0xc4>

ffffffffc0202dae <__slob_get_free_pages.isra.0>:
  struct Page * page = alloc_pages(1 << order);
ffffffffc0202dae:	4785                	li	a5,1
static void* __slob_get_free_pages(gfp_t gfp, int order)
ffffffffc0202db0:	1141                	addi	sp,sp,-16
  struct Page * page = alloc_pages(1 << order);
ffffffffc0202db2:	00a7953b          	sllw	a0,a5,a0
static void* __slob_get_free_pages(gfp_t gfp, int order)
ffffffffc0202db6:	e406                	sd	ra,8(sp)
  struct Page * page = alloc_pages(1 << order);
ffffffffc0202db8:	e03fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
  if(!page)
ffffffffc0202dbc:	c139                	beqz	a0,ffffffffc0202e02 <__slob_get_free_pages.isra.0+0x54>
    return page - pages + nbase;
ffffffffc0202dbe:	00012797          	auipc	a5,0x12
ffffffffc0202dc2:	73278793          	addi	a5,a5,1842 # ffffffffc02154f0 <pages>
ffffffffc0202dc6:	6394                	ld	a3,0(a5)
ffffffffc0202dc8:	00004797          	auipc	a5,0x4
ffffffffc0202dcc:	1d878793          	addi	a5,a5,472 # ffffffffc0206fa0 <nbase>
    return KADDR(page2pa(page));
ffffffffc0202dd0:	00012717          	auipc	a4,0x12
ffffffffc0202dd4:	6b870713          	addi	a4,a4,1720 # ffffffffc0215488 <npage>
    return page - pages + nbase;
ffffffffc0202dd8:	40d506b3          	sub	a3,a0,a3
ffffffffc0202ddc:	6388                	ld	a0,0(a5)
ffffffffc0202dde:	8699                	srai	a3,a3,0x6
    return KADDR(page2pa(page));
ffffffffc0202de0:	57fd                	li	a5,-1
ffffffffc0202de2:	6318                	ld	a4,0(a4)
    return page - pages + nbase;
ffffffffc0202de4:	96aa                	add	a3,a3,a0
    return KADDR(page2pa(page));
ffffffffc0202de6:	83b1                	srli	a5,a5,0xc
ffffffffc0202de8:	8ff5                	and	a5,a5,a3
    return page2ppn(page) << PGSHIFT;
ffffffffc0202dea:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc0202dec:	00e7ff63          	bleu	a4,a5,ffffffffc0202e0a <__slob_get_free_pages.isra.0+0x5c>
ffffffffc0202df0:	00012797          	auipc	a5,0x12
ffffffffc0202df4:	6f078793          	addi	a5,a5,1776 # ffffffffc02154e0 <va_pa_offset>
ffffffffc0202df8:	6388                	ld	a0,0(a5)
}
ffffffffc0202dfa:	60a2                	ld	ra,8(sp)
ffffffffc0202dfc:	9536                	add	a0,a0,a3
ffffffffc0202dfe:	0141                	addi	sp,sp,16
ffffffffc0202e00:	8082                	ret
ffffffffc0202e02:	60a2                	ld	ra,8(sp)
    return NULL;
ffffffffc0202e04:	4501                	li	a0,0
}
ffffffffc0202e06:	0141                	addi	sp,sp,16
ffffffffc0202e08:	8082                	ret
ffffffffc0202e0a:	00003617          	auipc	a2,0x3
ffffffffc0202e0e:	a2660613          	addi	a2,a2,-1498 # ffffffffc0205830 <commands+0x840>
ffffffffc0202e12:	06900593          	li	a1,105
ffffffffc0202e16:	00003517          	auipc	a0,0x3
ffffffffc0202e1a:	a7250513          	addi	a0,a0,-1422 # ffffffffc0205888 <commands+0x898>
ffffffffc0202e1e:	bb8fd0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0202e22 <slob_alloc.isra.1.constprop.3>:
static void *slob_alloc(size_t size, gfp_t gfp, int align)
ffffffffc0202e22:	7179                	addi	sp,sp,-48
ffffffffc0202e24:	f406                	sd	ra,40(sp)
ffffffffc0202e26:	f022                	sd	s0,32(sp)
ffffffffc0202e28:	ec26                	sd	s1,24(sp)
	assert( (size + SLOB_UNIT) < PAGE_SIZE );
ffffffffc0202e2a:	01050713          	addi	a4,a0,16
ffffffffc0202e2e:	6785                	lui	a5,0x1
ffffffffc0202e30:	0cf77b63          	bleu	a5,a4,ffffffffc0202f06 <slob_alloc.isra.1.constprop.3+0xe4>
	int delta = 0, units = SLOB_UNITS(size);
ffffffffc0202e34:	00f50413          	addi	s0,a0,15
ffffffffc0202e38:	8011                	srli	s0,s0,0x4
ffffffffc0202e3a:	2401                	sext.w	s0,s0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0202e3c:	10002673          	csrr	a2,sstatus
ffffffffc0202e40:	8a09                	andi	a2,a2,2
ffffffffc0202e42:	ea5d                	bnez	a2,ffffffffc0202ef8 <slob_alloc.isra.1.constprop.3+0xd6>
	prev = slobfree;
ffffffffc0202e44:	00007497          	auipc	s1,0x7
ffffffffc0202e48:	20c48493          	addi	s1,s1,524 # ffffffffc020a050 <slobfree>
ffffffffc0202e4c:	6094                	ld	a3,0(s1)
	for (cur = prev->next; ; prev = cur, cur = cur->next) {
ffffffffc0202e4e:	669c                	ld	a5,8(a3)
		if (cur->units >= units + delta) { /* room enough? */
ffffffffc0202e50:	4398                	lw	a4,0(a5)
ffffffffc0202e52:	0a875763          	ble	s0,a4,ffffffffc0202f00 <slob_alloc.isra.1.constprop.3+0xde>
		if (cur == slobfree) {
ffffffffc0202e56:	00f68a63          	beq	a3,a5,ffffffffc0202e6a <slob_alloc.isra.1.constprop.3+0x48>
	for (cur = prev->next; ; prev = cur, cur = cur->next) {
ffffffffc0202e5a:	6788                	ld	a0,8(a5)
		if (cur->units >= units + delta) { /* room enough? */
ffffffffc0202e5c:	4118                	lw	a4,0(a0)
ffffffffc0202e5e:	02875763          	ble	s0,a4,ffffffffc0202e8c <slob_alloc.isra.1.constprop.3+0x6a>
ffffffffc0202e62:	6094                	ld	a3,0(s1)
ffffffffc0202e64:	87aa                	mv	a5,a0
		if (cur == slobfree) {
ffffffffc0202e66:	fef69ae3          	bne	a3,a5,ffffffffc0202e5a <slob_alloc.isra.1.constprop.3+0x38>
    if (flag) {
ffffffffc0202e6a:	ea39                	bnez	a2,ffffffffc0202ec0 <slob_alloc.isra.1.constprop.3+0x9e>
			cur = (slob_t *)__slob_get_free_page(gfp);
ffffffffc0202e6c:	4501                	li	a0,0
ffffffffc0202e6e:	f41ff0ef          	jal	ra,ffffffffc0202dae <__slob_get_free_pages.isra.0>
			if (!cur)
ffffffffc0202e72:	cd29                	beqz	a0,ffffffffc0202ecc <slob_alloc.isra.1.constprop.3+0xaa>
			slob_free(cur, PAGE_SIZE);
ffffffffc0202e74:	6585                	lui	a1,0x1
ffffffffc0202e76:	e23ff0ef          	jal	ra,ffffffffc0202c98 <slob_free>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0202e7a:	10002673          	csrr	a2,sstatus
ffffffffc0202e7e:	8a09                	andi	a2,a2,2
ffffffffc0202e80:	ea1d                	bnez	a2,ffffffffc0202eb6 <slob_alloc.isra.1.constprop.3+0x94>
			cur = slobfree;
ffffffffc0202e82:	609c                	ld	a5,0(s1)
	for (cur = prev->next; ; prev = cur, cur = cur->next) {
ffffffffc0202e84:	6788                	ld	a0,8(a5)
		if (cur->units >= units + delta) { /* room enough? */
ffffffffc0202e86:	4118                	lw	a4,0(a0)
ffffffffc0202e88:	fc874de3          	blt	a4,s0,ffffffffc0202e62 <slob_alloc.isra.1.constprop.3+0x40>
			if (cur->units == units) /* exact fit? */
ffffffffc0202e8c:	04e40663          	beq	s0,a4,ffffffffc0202ed8 <slob_alloc.isra.1.constprop.3+0xb6>
				prev->next = cur + units;
ffffffffc0202e90:	00441693          	slli	a3,s0,0x4
ffffffffc0202e94:	96aa                	add	a3,a3,a0
ffffffffc0202e96:	e794                	sd	a3,8(a5)
				prev->next->next = cur->next;
ffffffffc0202e98:	650c                	ld	a1,8(a0)
				prev->next->units = cur->units - units;
ffffffffc0202e9a:	9f01                	subw	a4,a4,s0
ffffffffc0202e9c:	c298                	sw	a4,0(a3)
				prev->next->next = cur->next;
ffffffffc0202e9e:	e68c                	sd	a1,8(a3)
				cur->units = units;
ffffffffc0202ea0:	c100                	sw	s0,0(a0)
			slobfree = prev;
ffffffffc0202ea2:	00007717          	auipc	a4,0x7
ffffffffc0202ea6:	1af73723          	sd	a5,430(a4) # ffffffffc020a050 <slobfree>
    if (flag) {
ffffffffc0202eaa:	ee15                	bnez	a2,ffffffffc0202ee6 <slob_alloc.isra.1.constprop.3+0xc4>
}
ffffffffc0202eac:	70a2                	ld	ra,40(sp)
ffffffffc0202eae:	7402                	ld	s0,32(sp)
ffffffffc0202eb0:	64e2                	ld	s1,24(sp)
ffffffffc0202eb2:	6145                	addi	sp,sp,48
ffffffffc0202eb4:	8082                	ret
        intr_disable();
ffffffffc0202eb6:	f24fd0ef          	jal	ra,ffffffffc02005da <intr_disable>
ffffffffc0202eba:	4605                	li	a2,1
			cur = slobfree;
ffffffffc0202ebc:	609c                	ld	a5,0(s1)
ffffffffc0202ebe:	b7d9                	j	ffffffffc0202e84 <slob_alloc.isra.1.constprop.3+0x62>
        intr_enable();
ffffffffc0202ec0:	f14fd0ef          	jal	ra,ffffffffc02005d4 <intr_enable>
			cur = (slob_t *)__slob_get_free_page(gfp);
ffffffffc0202ec4:	4501                	li	a0,0
ffffffffc0202ec6:	ee9ff0ef          	jal	ra,ffffffffc0202dae <__slob_get_free_pages.isra.0>
			if (!cur)
ffffffffc0202eca:	f54d                	bnez	a0,ffffffffc0202e74 <slob_alloc.isra.1.constprop.3+0x52>
}
ffffffffc0202ecc:	70a2                	ld	ra,40(sp)
ffffffffc0202ece:	7402                	ld	s0,32(sp)
ffffffffc0202ed0:	64e2                	ld	s1,24(sp)
				return 0;
ffffffffc0202ed2:	4501                	li	a0,0
}
ffffffffc0202ed4:	6145                	addi	sp,sp,48
ffffffffc0202ed6:	8082                	ret
				prev->next = cur->next; /* unlink */
ffffffffc0202ed8:	6518                	ld	a4,8(a0)
ffffffffc0202eda:	e798                	sd	a4,8(a5)
			slobfree = prev;
ffffffffc0202edc:	00007717          	auipc	a4,0x7
ffffffffc0202ee0:	16f73a23          	sd	a5,372(a4) # ffffffffc020a050 <slobfree>
    if (flag) {
ffffffffc0202ee4:	d661                	beqz	a2,ffffffffc0202eac <slob_alloc.isra.1.constprop.3+0x8a>
ffffffffc0202ee6:	e42a                	sd	a0,8(sp)
        intr_enable();
ffffffffc0202ee8:	eecfd0ef          	jal	ra,ffffffffc02005d4 <intr_enable>
}
ffffffffc0202eec:	70a2                	ld	ra,40(sp)
ffffffffc0202eee:	7402                	ld	s0,32(sp)
ffffffffc0202ef0:	6522                	ld	a0,8(sp)
ffffffffc0202ef2:	64e2                	ld	s1,24(sp)
ffffffffc0202ef4:	6145                	addi	sp,sp,48
ffffffffc0202ef6:	8082                	ret
        intr_disable();
ffffffffc0202ef8:	ee2fd0ef          	jal	ra,ffffffffc02005da <intr_disable>
ffffffffc0202efc:	4605                	li	a2,1
ffffffffc0202efe:	b799                	j	ffffffffc0202e44 <slob_alloc.isra.1.constprop.3+0x22>
		if (cur->units >= units + delta) { /* room enough? */
ffffffffc0202f00:	853e                	mv	a0,a5
ffffffffc0202f02:	87b6                	mv	a5,a3
ffffffffc0202f04:	b761                	j	ffffffffc0202e8c <slob_alloc.isra.1.constprop.3+0x6a>
	assert( (size + SLOB_UNIT) < PAGE_SIZE );
ffffffffc0202f06:	00003697          	auipc	a3,0x3
ffffffffc0202f0a:	68a68693          	addi	a3,a3,1674 # ffffffffc0206590 <commands+0x15a0>
ffffffffc0202f0e:	00003617          	auipc	a2,0x3
ffffffffc0202f12:	a7a60613          	addi	a2,a2,-1414 # ffffffffc0205988 <commands+0x998>
ffffffffc0202f16:	06300593          	li	a1,99
ffffffffc0202f1a:	00003517          	auipc	a0,0x3
ffffffffc0202f1e:	69650513          	addi	a0,a0,1686 # ffffffffc02065b0 <commands+0x15c0>
ffffffffc0202f22:	ab4fd0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0202f26 <kmalloc_init>:
slob_init(void) {
  cprintf("use SLOB allocator\n");
}

inline void 
kmalloc_init(void) {
ffffffffc0202f26:	1141                	addi	sp,sp,-16
  cprintf("use SLOB allocator\n");
ffffffffc0202f28:	00003517          	auipc	a0,0x3
ffffffffc0202f2c:	6a050513          	addi	a0,a0,1696 # ffffffffc02065c8 <commands+0x15d8>
kmalloc_init(void) {
ffffffffc0202f30:	e406                	sd	ra,8(sp)
  cprintf("use SLOB allocator\n");
ffffffffc0202f32:	99efd0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    slob_init();
    cprintf("kmalloc_init() succeeded!\n");
}
ffffffffc0202f36:	60a2                	ld	ra,8(sp)
    cprintf("kmalloc_init() succeeded!\n");
ffffffffc0202f38:	00003517          	auipc	a0,0x3
ffffffffc0202f3c:	63850513          	addi	a0,a0,1592 # ffffffffc0206570 <commands+0x1580>
}
ffffffffc0202f40:	0141                	addi	sp,sp,16
    cprintf("kmalloc_init() succeeded!\n");
ffffffffc0202f42:	98efd06f          	j	ffffffffc02000d0 <cprintf>

ffffffffc0202f46 <kmalloc>:
	return 0;
}

void *
kmalloc(size_t size)
{
ffffffffc0202f46:	1101                	addi	sp,sp,-32
ffffffffc0202f48:	e04a                	sd	s2,0(sp)
	if (size < PAGE_SIZE - SLOB_UNIT) {
ffffffffc0202f4a:	6905                	lui	s2,0x1
{
ffffffffc0202f4c:	e822                	sd	s0,16(sp)
ffffffffc0202f4e:	ec06                	sd	ra,24(sp)
ffffffffc0202f50:	e426                	sd	s1,8(sp)
	if (size < PAGE_SIZE - SLOB_UNIT) {
ffffffffc0202f52:	fef90793          	addi	a5,s2,-17 # fef <BASE_ADDRESS-0xffffffffc01ff011>
{
ffffffffc0202f56:	842a                	mv	s0,a0
	if (size < PAGE_SIZE - SLOB_UNIT) {
ffffffffc0202f58:	04a7fc63          	bleu	a0,a5,ffffffffc0202fb0 <kmalloc+0x6a>
	bb = slob_alloc(sizeof(bigblock_t), gfp, 0);
ffffffffc0202f5c:	4561                	li	a0,24
ffffffffc0202f5e:	ec5ff0ef          	jal	ra,ffffffffc0202e22 <slob_alloc.isra.1.constprop.3>
ffffffffc0202f62:	84aa                	mv	s1,a0
	if (!bb)
ffffffffc0202f64:	cd21                	beqz	a0,ffffffffc0202fbc <kmalloc+0x76>
	bb->order = find_order(size);
ffffffffc0202f66:	0004079b          	sext.w	a5,s0
	int order = 0;
ffffffffc0202f6a:	4501                	li	a0,0
	for ( ; size > 4096 ; size >>=1)
ffffffffc0202f6c:	00f95763          	ble	a5,s2,ffffffffc0202f7a <kmalloc+0x34>
ffffffffc0202f70:	6705                	lui	a4,0x1
ffffffffc0202f72:	8785                	srai	a5,a5,0x1
		order++;
ffffffffc0202f74:	2505                	addiw	a0,a0,1
	for ( ; size > 4096 ; size >>=1)
ffffffffc0202f76:	fef74ee3          	blt	a4,a5,ffffffffc0202f72 <kmalloc+0x2c>
	bb->order = find_order(size);
ffffffffc0202f7a:	c088                	sw	a0,0(s1)
	bb->pages = (void *)__slob_get_free_pages(gfp, bb->order);
ffffffffc0202f7c:	e33ff0ef          	jal	ra,ffffffffc0202dae <__slob_get_free_pages.isra.0>
ffffffffc0202f80:	e488                	sd	a0,8(s1)
ffffffffc0202f82:	842a                	mv	s0,a0
	if (bb->pages) {
ffffffffc0202f84:	c935                	beqz	a0,ffffffffc0202ff8 <kmalloc+0xb2>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0202f86:	100027f3          	csrr	a5,sstatus
ffffffffc0202f8a:	8b89                	andi	a5,a5,2
ffffffffc0202f8c:	e3a1                	bnez	a5,ffffffffc0202fcc <kmalloc+0x86>
		bb->next = bigblocks;
ffffffffc0202f8e:	00012797          	auipc	a5,0x12
ffffffffc0202f92:	51a78793          	addi	a5,a5,1306 # ffffffffc02154a8 <bigblocks>
ffffffffc0202f96:	639c                	ld	a5,0(a5)
		bigblocks = bb;
ffffffffc0202f98:	00012717          	auipc	a4,0x12
ffffffffc0202f9c:	50973823          	sd	s1,1296(a4) # ffffffffc02154a8 <bigblocks>
		bb->next = bigblocks;
ffffffffc0202fa0:	e89c                	sd	a5,16(s1)
  return __kmalloc(size, 0);
}
ffffffffc0202fa2:	8522                	mv	a0,s0
ffffffffc0202fa4:	60e2                	ld	ra,24(sp)
ffffffffc0202fa6:	6442                	ld	s0,16(sp)
ffffffffc0202fa8:	64a2                	ld	s1,8(sp)
ffffffffc0202faa:	6902                	ld	s2,0(sp)
ffffffffc0202fac:	6105                	addi	sp,sp,32
ffffffffc0202fae:	8082                	ret
		m = slob_alloc(size + SLOB_UNIT, gfp, 0);
ffffffffc0202fb0:	0541                	addi	a0,a0,16
ffffffffc0202fb2:	e71ff0ef          	jal	ra,ffffffffc0202e22 <slob_alloc.isra.1.constprop.3>
		return m ? (void *)(m + 1) : 0;
ffffffffc0202fb6:	01050413          	addi	s0,a0,16
ffffffffc0202fba:	f565                	bnez	a0,ffffffffc0202fa2 <kmalloc+0x5c>
ffffffffc0202fbc:	4401                	li	s0,0
}
ffffffffc0202fbe:	8522                	mv	a0,s0
ffffffffc0202fc0:	60e2                	ld	ra,24(sp)
ffffffffc0202fc2:	6442                	ld	s0,16(sp)
ffffffffc0202fc4:	64a2                	ld	s1,8(sp)
ffffffffc0202fc6:	6902                	ld	s2,0(sp)
ffffffffc0202fc8:	6105                	addi	sp,sp,32
ffffffffc0202fca:	8082                	ret
        intr_disable();
ffffffffc0202fcc:	e0efd0ef          	jal	ra,ffffffffc02005da <intr_disable>
		bb->next = bigblocks;
ffffffffc0202fd0:	00012797          	auipc	a5,0x12
ffffffffc0202fd4:	4d878793          	addi	a5,a5,1240 # ffffffffc02154a8 <bigblocks>
ffffffffc0202fd8:	639c                	ld	a5,0(a5)
		bigblocks = bb;
ffffffffc0202fda:	00012717          	auipc	a4,0x12
ffffffffc0202fde:	4c973723          	sd	s1,1230(a4) # ffffffffc02154a8 <bigblocks>
		bb->next = bigblocks;
ffffffffc0202fe2:	e89c                	sd	a5,16(s1)
        intr_enable();
ffffffffc0202fe4:	df0fd0ef          	jal	ra,ffffffffc02005d4 <intr_enable>
ffffffffc0202fe8:	6480                	ld	s0,8(s1)
}
ffffffffc0202fea:	60e2                	ld	ra,24(sp)
ffffffffc0202fec:	64a2                	ld	s1,8(sp)
ffffffffc0202fee:	8522                	mv	a0,s0
ffffffffc0202ff0:	6442                	ld	s0,16(sp)
ffffffffc0202ff2:	6902                	ld	s2,0(sp)
ffffffffc0202ff4:	6105                	addi	sp,sp,32
ffffffffc0202ff6:	8082                	ret
	slob_free(bb, sizeof(bigblock_t));
ffffffffc0202ff8:	45e1                	li	a1,24
ffffffffc0202ffa:	8526                	mv	a0,s1
ffffffffc0202ffc:	c9dff0ef          	jal	ra,ffffffffc0202c98 <slob_free>
  return __kmalloc(size, 0);
ffffffffc0203000:	b74d                	j	ffffffffc0202fa2 <kmalloc+0x5c>

ffffffffc0203002 <kfree>:
void kfree(void *block)
{
	bigblock_t *bb, **last = &bigblocks;
	unsigned long flags;

	if (!block)
ffffffffc0203002:	c175                	beqz	a0,ffffffffc02030e6 <kfree+0xe4>
{
ffffffffc0203004:	1101                	addi	sp,sp,-32
ffffffffc0203006:	e426                	sd	s1,8(sp)
ffffffffc0203008:	ec06                	sd	ra,24(sp)
ffffffffc020300a:	e822                	sd	s0,16(sp)
		return;

	if (!((unsigned long)block & (PAGE_SIZE-1))) {
ffffffffc020300c:	03451793          	slli	a5,a0,0x34
ffffffffc0203010:	84aa                	mv	s1,a0
ffffffffc0203012:	eb8d                	bnez	a5,ffffffffc0203044 <kfree+0x42>
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0203014:	100027f3          	csrr	a5,sstatus
ffffffffc0203018:	8b89                	andi	a5,a5,2
ffffffffc020301a:	efc9                	bnez	a5,ffffffffc02030b4 <kfree+0xb2>
		/* might be on the big block list */
		spin_lock_irqsave(&block_lock, flags);
		for (bb = bigblocks; bb; last = &bb->next, bb = bb->next) {
ffffffffc020301c:	00012797          	auipc	a5,0x12
ffffffffc0203020:	48c78793          	addi	a5,a5,1164 # ffffffffc02154a8 <bigblocks>
ffffffffc0203024:	6394                	ld	a3,0(a5)
ffffffffc0203026:	ce99                	beqz	a3,ffffffffc0203044 <kfree+0x42>
			if (bb->pages == block) {
ffffffffc0203028:	669c                	ld	a5,8(a3)
ffffffffc020302a:	6a80                	ld	s0,16(a3)
ffffffffc020302c:	0af50e63          	beq	a0,a5,ffffffffc02030e8 <kfree+0xe6>
    return 0;
ffffffffc0203030:	4601                	li	a2,0
		for (bb = bigblocks; bb; last = &bb->next, bb = bb->next) {
ffffffffc0203032:	c801                	beqz	s0,ffffffffc0203042 <kfree+0x40>
			if (bb->pages == block) {
ffffffffc0203034:	6418                	ld	a4,8(s0)
ffffffffc0203036:	681c                	ld	a5,16(s0)
ffffffffc0203038:	00970f63          	beq	a4,s1,ffffffffc0203056 <kfree+0x54>
ffffffffc020303c:	86a2                	mv	a3,s0
ffffffffc020303e:	843e                	mv	s0,a5
		for (bb = bigblocks; bb; last = &bb->next, bb = bb->next) {
ffffffffc0203040:	f875                	bnez	s0,ffffffffc0203034 <kfree+0x32>
    if (flag) {
ffffffffc0203042:	e659                	bnez	a2,ffffffffc02030d0 <kfree+0xce>
		spin_unlock_irqrestore(&block_lock, flags);
	}

	slob_free((slob_t *)block - 1, 0);
	return;
}
ffffffffc0203044:	6442                	ld	s0,16(sp)
ffffffffc0203046:	60e2                	ld	ra,24(sp)
	slob_free((slob_t *)block - 1, 0);
ffffffffc0203048:	ff048513          	addi	a0,s1,-16
}
ffffffffc020304c:	64a2                	ld	s1,8(sp)
	slob_free((slob_t *)block - 1, 0);
ffffffffc020304e:	4581                	li	a1,0
}
ffffffffc0203050:	6105                	addi	sp,sp,32
	slob_free((slob_t *)block - 1, 0);
ffffffffc0203052:	c47ff06f          	j	ffffffffc0202c98 <slob_free>
				*last = bb->next;
ffffffffc0203056:	ea9c                	sd	a5,16(a3)
ffffffffc0203058:	e641                	bnez	a2,ffffffffc02030e0 <kfree+0xde>
    return pa2page(PADDR(kva));
ffffffffc020305a:	c02007b7          	lui	a5,0xc0200
				__slob_free_pages((unsigned long)block, bb->order);
ffffffffc020305e:	4018                	lw	a4,0(s0)
ffffffffc0203060:	08f4ea63          	bltu	s1,a5,ffffffffc02030f4 <kfree+0xf2>
ffffffffc0203064:	00012797          	auipc	a5,0x12
ffffffffc0203068:	47c78793          	addi	a5,a5,1148 # ffffffffc02154e0 <va_pa_offset>
ffffffffc020306c:	6394                	ld	a3,0(a5)
    if (PPN(pa) >= npage) {
ffffffffc020306e:	00012797          	auipc	a5,0x12
ffffffffc0203072:	41a78793          	addi	a5,a5,1050 # ffffffffc0215488 <npage>
ffffffffc0203076:	639c                	ld	a5,0(a5)
    return pa2page(PADDR(kva));
ffffffffc0203078:	8c95                	sub	s1,s1,a3
    if (PPN(pa) >= npage) {
ffffffffc020307a:	80b1                	srli	s1,s1,0xc
ffffffffc020307c:	08f4f963          	bleu	a5,s1,ffffffffc020310e <kfree+0x10c>
    return &pages[PPN(pa) - nbase];
ffffffffc0203080:	00004797          	auipc	a5,0x4
ffffffffc0203084:	f2078793          	addi	a5,a5,-224 # ffffffffc0206fa0 <nbase>
ffffffffc0203088:	639c                	ld	a5,0(a5)
ffffffffc020308a:	00012697          	auipc	a3,0x12
ffffffffc020308e:	46668693          	addi	a3,a3,1126 # ffffffffc02154f0 <pages>
ffffffffc0203092:	6288                	ld	a0,0(a3)
ffffffffc0203094:	8c9d                	sub	s1,s1,a5
ffffffffc0203096:	049a                	slli	s1,s1,0x6
  free_pages(kva2page(kva), 1 << order);
ffffffffc0203098:	4585                	li	a1,1
ffffffffc020309a:	9526                	add	a0,a0,s1
ffffffffc020309c:	00e595bb          	sllw	a1,a1,a4
ffffffffc02030a0:	ba3fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
				slob_free(bb, sizeof(bigblock_t));
ffffffffc02030a4:	8522                	mv	a0,s0
}
ffffffffc02030a6:	6442                	ld	s0,16(sp)
ffffffffc02030a8:	60e2                	ld	ra,24(sp)
ffffffffc02030aa:	64a2                	ld	s1,8(sp)
				slob_free(bb, sizeof(bigblock_t));
ffffffffc02030ac:	45e1                	li	a1,24
}
ffffffffc02030ae:	6105                	addi	sp,sp,32
	slob_free((slob_t *)block - 1, 0);
ffffffffc02030b0:	be9ff06f          	j	ffffffffc0202c98 <slob_free>
        intr_disable();
ffffffffc02030b4:	d26fd0ef          	jal	ra,ffffffffc02005da <intr_disable>
		for (bb = bigblocks; bb; last = &bb->next, bb = bb->next) {
ffffffffc02030b8:	00012797          	auipc	a5,0x12
ffffffffc02030bc:	3f078793          	addi	a5,a5,1008 # ffffffffc02154a8 <bigblocks>
ffffffffc02030c0:	6394                	ld	a3,0(a5)
ffffffffc02030c2:	c699                	beqz	a3,ffffffffc02030d0 <kfree+0xce>
			if (bb->pages == block) {
ffffffffc02030c4:	669c                	ld	a5,8(a3)
ffffffffc02030c6:	6a80                	ld	s0,16(a3)
ffffffffc02030c8:	00f48763          	beq	s1,a5,ffffffffc02030d6 <kfree+0xd4>
        return 1;
ffffffffc02030cc:	4605                	li	a2,1
ffffffffc02030ce:	b795                	j	ffffffffc0203032 <kfree+0x30>
        intr_enable();
ffffffffc02030d0:	d04fd0ef          	jal	ra,ffffffffc02005d4 <intr_enable>
ffffffffc02030d4:	bf85                	j	ffffffffc0203044 <kfree+0x42>
				*last = bb->next;
ffffffffc02030d6:	00012797          	auipc	a5,0x12
ffffffffc02030da:	3c87b923          	sd	s0,978(a5) # ffffffffc02154a8 <bigblocks>
ffffffffc02030de:	8436                	mv	s0,a3
ffffffffc02030e0:	cf4fd0ef          	jal	ra,ffffffffc02005d4 <intr_enable>
ffffffffc02030e4:	bf9d                	j	ffffffffc020305a <kfree+0x58>
ffffffffc02030e6:	8082                	ret
ffffffffc02030e8:	00012797          	auipc	a5,0x12
ffffffffc02030ec:	3c87b023          	sd	s0,960(a5) # ffffffffc02154a8 <bigblocks>
ffffffffc02030f0:	8436                	mv	s0,a3
ffffffffc02030f2:	b7a5                	j	ffffffffc020305a <kfree+0x58>
    return pa2page(PADDR(kva));
ffffffffc02030f4:	86a6                	mv	a3,s1
ffffffffc02030f6:	00003617          	auipc	a2,0x3
ffffffffc02030fa:	81260613          	addi	a2,a2,-2030 # ffffffffc0205908 <commands+0x918>
ffffffffc02030fe:	06e00593          	li	a1,110
ffffffffc0203102:	00002517          	auipc	a0,0x2
ffffffffc0203106:	78650513          	addi	a0,a0,1926 # ffffffffc0205888 <commands+0x898>
ffffffffc020310a:	8ccfd0ef          	jal	ra,ffffffffc02001d6 <__panic>
        panic("pa2page called with invalid pa");
ffffffffc020310e:	00002617          	auipc	a2,0x2
ffffffffc0203112:	75a60613          	addi	a2,a2,1882 # ffffffffc0205868 <commands+0x878>
ffffffffc0203116:	06200593          	li	a1,98
ffffffffc020311a:	00002517          	auipc	a0,0x2
ffffffffc020311e:	76e50513          	addi	a0,a0,1902 # ffffffffc0205888 <commands+0x898>
ffffffffc0203122:	8b4fd0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0203126 <_fifo_init_mm>:
    elm->prev = elm->next = elm;
ffffffffc0203126:	00012797          	auipc	a5,0x12
ffffffffc020312a:	4a278793          	addi	a5,a5,1186 # ffffffffc02155c8 <pra_list_head>
 */
static int
_fifo_init_mm(struct mm_struct *mm)
{     
     list_init(&pra_list_head);
     mm->sm_priv = &pra_list_head;
ffffffffc020312e:	f51c                	sd	a5,40(a0)
ffffffffc0203130:	e79c                	sd	a5,8(a5)
ffffffffc0203132:	e39c                	sd	a5,0(a5)
     //cprintf(" mm->sm_priv %x in fifo_init_mm\n",mm->sm_priv);
     return 0;
}
ffffffffc0203134:	4501                	li	a0,0
ffffffffc0203136:	8082                	ret

ffffffffc0203138 <_fifo_init>:

static int
_fifo_init(void)
{
    return 0;
}
ffffffffc0203138:	4501                	li	a0,0
ffffffffc020313a:	8082                	ret

ffffffffc020313c <_fifo_set_unswappable>:

static int
_fifo_set_unswappable(struct mm_struct *mm, uintptr_t addr)
{
    return 0;
}
ffffffffc020313c:	4501                	li	a0,0
ffffffffc020313e:	8082                	ret

ffffffffc0203140 <_fifo_tick_event>:

static int
_fifo_tick_event(struct mm_struct *mm)
{ return 0; }
ffffffffc0203140:	4501                	li	a0,0
ffffffffc0203142:	8082                	ret

ffffffffc0203144 <_fifo_check_swap>:
_fifo_check_swap(void) {
ffffffffc0203144:	711d                	addi	sp,sp,-96
ffffffffc0203146:	fc4e                	sd	s3,56(sp)
ffffffffc0203148:	f852                	sd	s4,48(sp)
    cprintf("write Virt Page c in fifo_check_swap\n");
ffffffffc020314a:	00003517          	auipc	a0,0x3
ffffffffc020314e:	49650513          	addi	a0,a0,1174 # ffffffffc02065e0 <commands+0x15f0>
    *(unsigned char *)0x3000 = 0x0c;
ffffffffc0203152:	698d                	lui	s3,0x3
ffffffffc0203154:	4a31                	li	s4,12
_fifo_check_swap(void) {
ffffffffc0203156:	e8a2                	sd	s0,80(sp)
ffffffffc0203158:	e4a6                	sd	s1,72(sp)
ffffffffc020315a:	ec86                	sd	ra,88(sp)
ffffffffc020315c:	e0ca                	sd	s2,64(sp)
ffffffffc020315e:	f456                	sd	s5,40(sp)
ffffffffc0203160:	f05a                	sd	s6,32(sp)
ffffffffc0203162:	ec5e                	sd	s7,24(sp)
ffffffffc0203164:	e862                	sd	s8,16(sp)
ffffffffc0203166:	e466                	sd	s9,8(sp)
    assert(pgfault_num==4);
ffffffffc0203168:	00012417          	auipc	s0,0x12
ffffffffc020316c:	32840413          	addi	s0,s0,808 # ffffffffc0215490 <pgfault_num>
    cprintf("write Virt Page c in fifo_check_swap\n");
ffffffffc0203170:	f61fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x3000 = 0x0c;
ffffffffc0203174:	01498023          	sb	s4,0(s3) # 3000 <BASE_ADDRESS-0xffffffffc01fd000>
    assert(pgfault_num==4);
ffffffffc0203178:	4004                	lw	s1,0(s0)
ffffffffc020317a:	4791                	li	a5,4
ffffffffc020317c:	2481                	sext.w	s1,s1
ffffffffc020317e:	14f49963          	bne	s1,a5,ffffffffc02032d0 <_fifo_check_swap+0x18c>
    cprintf("write Virt Page a in fifo_check_swap\n");
ffffffffc0203182:	00003517          	auipc	a0,0x3
ffffffffc0203186:	49e50513          	addi	a0,a0,1182 # ffffffffc0206620 <commands+0x1630>
    *(unsigned char *)0x1000 = 0x0a;
ffffffffc020318a:	6a85                	lui	s5,0x1
ffffffffc020318c:	4b29                	li	s6,10
    cprintf("write Virt Page a in fifo_check_swap\n");
ffffffffc020318e:	f43fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x1000 = 0x0a;
ffffffffc0203192:	016a8023          	sb	s6,0(s5) # 1000 <BASE_ADDRESS-0xffffffffc01ff000>
    assert(pgfault_num==4);
ffffffffc0203196:	00042903          	lw	s2,0(s0)
ffffffffc020319a:	2901                	sext.w	s2,s2
ffffffffc020319c:	2a991a63          	bne	s2,s1,ffffffffc0203450 <_fifo_check_swap+0x30c>
    cprintf("write Virt Page d in fifo_check_swap\n");
ffffffffc02031a0:	00003517          	auipc	a0,0x3
ffffffffc02031a4:	4a850513          	addi	a0,a0,1192 # ffffffffc0206648 <commands+0x1658>
    *(unsigned char *)0x4000 = 0x0d;
ffffffffc02031a8:	6b91                	lui	s7,0x4
ffffffffc02031aa:	4c35                	li	s8,13
    cprintf("write Virt Page d in fifo_check_swap\n");
ffffffffc02031ac:	f25fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x4000 = 0x0d;
ffffffffc02031b0:	018b8023          	sb	s8,0(s7) # 4000 <BASE_ADDRESS-0xffffffffc01fc000>
    assert(pgfault_num==4);
ffffffffc02031b4:	4004                	lw	s1,0(s0)
ffffffffc02031b6:	2481                	sext.w	s1,s1
ffffffffc02031b8:	27249c63          	bne	s1,s2,ffffffffc0203430 <_fifo_check_swap+0x2ec>
    cprintf("write Virt Page b in fifo_check_swap\n");
ffffffffc02031bc:	00003517          	auipc	a0,0x3
ffffffffc02031c0:	4b450513          	addi	a0,a0,1204 # ffffffffc0206670 <commands+0x1680>
    *(unsigned char *)0x2000 = 0x0b;
ffffffffc02031c4:	6909                	lui	s2,0x2
ffffffffc02031c6:	4cad                	li	s9,11
    cprintf("write Virt Page b in fifo_check_swap\n");
ffffffffc02031c8:	f09fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x2000 = 0x0b;
ffffffffc02031cc:	01990023          	sb	s9,0(s2) # 2000 <BASE_ADDRESS-0xffffffffc01fe000>
    assert(pgfault_num==4);
ffffffffc02031d0:	401c                	lw	a5,0(s0)
ffffffffc02031d2:	2781                	sext.w	a5,a5
ffffffffc02031d4:	22979e63          	bne	a5,s1,ffffffffc0203410 <_fifo_check_swap+0x2cc>
    cprintf("write Virt Page e in fifo_check_swap\n");
ffffffffc02031d8:	00003517          	auipc	a0,0x3
ffffffffc02031dc:	4c050513          	addi	a0,a0,1216 # ffffffffc0206698 <commands+0x16a8>
ffffffffc02031e0:	ef1fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x5000 = 0x0e;
ffffffffc02031e4:	6795                	lui	a5,0x5
ffffffffc02031e6:	4739                	li	a4,14
ffffffffc02031e8:	00e78023          	sb	a4,0(a5) # 5000 <BASE_ADDRESS-0xffffffffc01fb000>
    assert(pgfault_num==5);
ffffffffc02031ec:	4004                	lw	s1,0(s0)
ffffffffc02031ee:	4795                	li	a5,5
ffffffffc02031f0:	2481                	sext.w	s1,s1
ffffffffc02031f2:	1ef49f63          	bne	s1,a5,ffffffffc02033f0 <_fifo_check_swap+0x2ac>
    cprintf("write Virt Page b in fifo_check_swap\n");
ffffffffc02031f6:	00003517          	auipc	a0,0x3
ffffffffc02031fa:	47a50513          	addi	a0,a0,1146 # ffffffffc0206670 <commands+0x1680>
ffffffffc02031fe:	ed3fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x2000 = 0x0b;
ffffffffc0203202:	01990023          	sb	s9,0(s2)
    assert(pgfault_num==5);
ffffffffc0203206:	401c                	lw	a5,0(s0)
ffffffffc0203208:	2781                	sext.w	a5,a5
ffffffffc020320a:	1c979363          	bne	a5,s1,ffffffffc02033d0 <_fifo_check_swap+0x28c>
    cprintf("write Virt Page a in fifo_check_swap\n");
ffffffffc020320e:	00003517          	auipc	a0,0x3
ffffffffc0203212:	41250513          	addi	a0,a0,1042 # ffffffffc0206620 <commands+0x1630>
ffffffffc0203216:	ebbfc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x1000 = 0x0a;
ffffffffc020321a:	016a8023          	sb	s6,0(s5)
    assert(pgfault_num==6);
ffffffffc020321e:	401c                	lw	a5,0(s0)
ffffffffc0203220:	4719                	li	a4,6
ffffffffc0203222:	2781                	sext.w	a5,a5
ffffffffc0203224:	18e79663          	bne	a5,a4,ffffffffc02033b0 <_fifo_check_swap+0x26c>
    cprintf("write Virt Page b in fifo_check_swap\n");
ffffffffc0203228:	00003517          	auipc	a0,0x3
ffffffffc020322c:	44850513          	addi	a0,a0,1096 # ffffffffc0206670 <commands+0x1680>
ffffffffc0203230:	ea1fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x2000 = 0x0b;
ffffffffc0203234:	01990023          	sb	s9,0(s2)
    assert(pgfault_num==7);
ffffffffc0203238:	401c                	lw	a5,0(s0)
ffffffffc020323a:	471d                	li	a4,7
ffffffffc020323c:	2781                	sext.w	a5,a5
ffffffffc020323e:	14e79963          	bne	a5,a4,ffffffffc0203390 <_fifo_check_swap+0x24c>
    cprintf("write Virt Page c in fifo_check_swap\n");
ffffffffc0203242:	00003517          	auipc	a0,0x3
ffffffffc0203246:	39e50513          	addi	a0,a0,926 # ffffffffc02065e0 <commands+0x15f0>
ffffffffc020324a:	e87fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x3000 = 0x0c;
ffffffffc020324e:	01498023          	sb	s4,0(s3)
    assert(pgfault_num==8);
ffffffffc0203252:	401c                	lw	a5,0(s0)
ffffffffc0203254:	4721                	li	a4,8
ffffffffc0203256:	2781                	sext.w	a5,a5
ffffffffc0203258:	10e79c63          	bne	a5,a4,ffffffffc0203370 <_fifo_check_swap+0x22c>
    cprintf("write Virt Page d in fifo_check_swap\n");
ffffffffc020325c:	00003517          	auipc	a0,0x3
ffffffffc0203260:	3ec50513          	addi	a0,a0,1004 # ffffffffc0206648 <commands+0x1658>
ffffffffc0203264:	e6dfc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x4000 = 0x0d;
ffffffffc0203268:	018b8023          	sb	s8,0(s7)
    assert(pgfault_num==9);
ffffffffc020326c:	401c                	lw	a5,0(s0)
ffffffffc020326e:	4725                	li	a4,9
ffffffffc0203270:	2781                	sext.w	a5,a5
ffffffffc0203272:	0ce79f63          	bne	a5,a4,ffffffffc0203350 <_fifo_check_swap+0x20c>
    cprintf("write Virt Page e in fifo_check_swap\n");
ffffffffc0203276:	00003517          	auipc	a0,0x3
ffffffffc020327a:	42250513          	addi	a0,a0,1058 # ffffffffc0206698 <commands+0x16a8>
ffffffffc020327e:	e53fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    *(unsigned char *)0x5000 = 0x0e;
ffffffffc0203282:	6795                	lui	a5,0x5
ffffffffc0203284:	4739                	li	a4,14
ffffffffc0203286:	00e78023          	sb	a4,0(a5) # 5000 <BASE_ADDRESS-0xffffffffc01fb000>
    assert(pgfault_num==10);
ffffffffc020328a:	4004                	lw	s1,0(s0)
ffffffffc020328c:	47a9                	li	a5,10
ffffffffc020328e:	2481                	sext.w	s1,s1
ffffffffc0203290:	0af49063          	bne	s1,a5,ffffffffc0203330 <_fifo_check_swap+0x1ec>
    cprintf("write Virt Page a in fifo_check_swap\n");
ffffffffc0203294:	00003517          	auipc	a0,0x3
ffffffffc0203298:	38c50513          	addi	a0,a0,908 # ffffffffc0206620 <commands+0x1630>
ffffffffc020329c:	e35fc0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    assert(*(unsigned char *)0x1000 == 0x0a);
ffffffffc02032a0:	6785                	lui	a5,0x1
ffffffffc02032a2:	0007c783          	lbu	a5,0(a5) # 1000 <BASE_ADDRESS-0xffffffffc01ff000>
ffffffffc02032a6:	06979563          	bne	a5,s1,ffffffffc0203310 <_fifo_check_swap+0x1cc>
    assert(pgfault_num==11);
ffffffffc02032aa:	401c                	lw	a5,0(s0)
ffffffffc02032ac:	472d                	li	a4,11
ffffffffc02032ae:	2781                	sext.w	a5,a5
ffffffffc02032b0:	04e79063          	bne	a5,a4,ffffffffc02032f0 <_fifo_check_swap+0x1ac>
}
ffffffffc02032b4:	60e6                	ld	ra,88(sp)
ffffffffc02032b6:	6446                	ld	s0,80(sp)
ffffffffc02032b8:	64a6                	ld	s1,72(sp)
ffffffffc02032ba:	6906                	ld	s2,64(sp)
ffffffffc02032bc:	79e2                	ld	s3,56(sp)
ffffffffc02032be:	7a42                	ld	s4,48(sp)
ffffffffc02032c0:	7aa2                	ld	s5,40(sp)
ffffffffc02032c2:	7b02                	ld	s6,32(sp)
ffffffffc02032c4:	6be2                	ld	s7,24(sp)
ffffffffc02032c6:	6c42                	ld	s8,16(sp)
ffffffffc02032c8:	6ca2                	ld	s9,8(sp)
ffffffffc02032ca:	4501                	li	a0,0
ffffffffc02032cc:	6125                	addi	sp,sp,96
ffffffffc02032ce:	8082                	ret
    assert(pgfault_num==4);
ffffffffc02032d0:	00003697          	auipc	a3,0x3
ffffffffc02032d4:	13068693          	addi	a3,a3,304 # ffffffffc0206400 <commands+0x1410>
ffffffffc02032d8:	00002617          	auipc	a2,0x2
ffffffffc02032dc:	6b060613          	addi	a2,a2,1712 # ffffffffc0205988 <commands+0x998>
ffffffffc02032e0:	05100593          	li	a1,81
ffffffffc02032e4:	00003517          	auipc	a0,0x3
ffffffffc02032e8:	32450513          	addi	a0,a0,804 # ffffffffc0206608 <commands+0x1618>
ffffffffc02032ec:	eebfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==11);
ffffffffc02032f0:	00003697          	auipc	a3,0x3
ffffffffc02032f4:	45868693          	addi	a3,a3,1112 # ffffffffc0206748 <commands+0x1758>
ffffffffc02032f8:	00002617          	auipc	a2,0x2
ffffffffc02032fc:	69060613          	addi	a2,a2,1680 # ffffffffc0205988 <commands+0x998>
ffffffffc0203300:	07300593          	li	a1,115
ffffffffc0203304:	00003517          	auipc	a0,0x3
ffffffffc0203308:	30450513          	addi	a0,a0,772 # ffffffffc0206608 <commands+0x1618>
ffffffffc020330c:	ecbfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(*(unsigned char *)0x1000 == 0x0a);
ffffffffc0203310:	00003697          	auipc	a3,0x3
ffffffffc0203314:	41068693          	addi	a3,a3,1040 # ffffffffc0206720 <commands+0x1730>
ffffffffc0203318:	00002617          	auipc	a2,0x2
ffffffffc020331c:	67060613          	addi	a2,a2,1648 # ffffffffc0205988 <commands+0x998>
ffffffffc0203320:	07100593          	li	a1,113
ffffffffc0203324:	00003517          	auipc	a0,0x3
ffffffffc0203328:	2e450513          	addi	a0,a0,740 # ffffffffc0206608 <commands+0x1618>
ffffffffc020332c:	eabfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==10);
ffffffffc0203330:	00003697          	auipc	a3,0x3
ffffffffc0203334:	3e068693          	addi	a3,a3,992 # ffffffffc0206710 <commands+0x1720>
ffffffffc0203338:	00002617          	auipc	a2,0x2
ffffffffc020333c:	65060613          	addi	a2,a2,1616 # ffffffffc0205988 <commands+0x998>
ffffffffc0203340:	06f00593          	li	a1,111
ffffffffc0203344:	00003517          	auipc	a0,0x3
ffffffffc0203348:	2c450513          	addi	a0,a0,708 # ffffffffc0206608 <commands+0x1618>
ffffffffc020334c:	e8bfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==9);
ffffffffc0203350:	00003697          	auipc	a3,0x3
ffffffffc0203354:	3b068693          	addi	a3,a3,944 # ffffffffc0206700 <commands+0x1710>
ffffffffc0203358:	00002617          	auipc	a2,0x2
ffffffffc020335c:	63060613          	addi	a2,a2,1584 # ffffffffc0205988 <commands+0x998>
ffffffffc0203360:	06c00593          	li	a1,108
ffffffffc0203364:	00003517          	auipc	a0,0x3
ffffffffc0203368:	2a450513          	addi	a0,a0,676 # ffffffffc0206608 <commands+0x1618>
ffffffffc020336c:	e6bfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==8);
ffffffffc0203370:	00003697          	auipc	a3,0x3
ffffffffc0203374:	38068693          	addi	a3,a3,896 # ffffffffc02066f0 <commands+0x1700>
ffffffffc0203378:	00002617          	auipc	a2,0x2
ffffffffc020337c:	61060613          	addi	a2,a2,1552 # ffffffffc0205988 <commands+0x998>
ffffffffc0203380:	06900593          	li	a1,105
ffffffffc0203384:	00003517          	auipc	a0,0x3
ffffffffc0203388:	28450513          	addi	a0,a0,644 # ffffffffc0206608 <commands+0x1618>
ffffffffc020338c:	e4bfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==7);
ffffffffc0203390:	00003697          	auipc	a3,0x3
ffffffffc0203394:	35068693          	addi	a3,a3,848 # ffffffffc02066e0 <commands+0x16f0>
ffffffffc0203398:	00002617          	auipc	a2,0x2
ffffffffc020339c:	5f060613          	addi	a2,a2,1520 # ffffffffc0205988 <commands+0x998>
ffffffffc02033a0:	06600593          	li	a1,102
ffffffffc02033a4:	00003517          	auipc	a0,0x3
ffffffffc02033a8:	26450513          	addi	a0,a0,612 # ffffffffc0206608 <commands+0x1618>
ffffffffc02033ac:	e2bfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==6);
ffffffffc02033b0:	00003697          	auipc	a3,0x3
ffffffffc02033b4:	32068693          	addi	a3,a3,800 # ffffffffc02066d0 <commands+0x16e0>
ffffffffc02033b8:	00002617          	auipc	a2,0x2
ffffffffc02033bc:	5d060613          	addi	a2,a2,1488 # ffffffffc0205988 <commands+0x998>
ffffffffc02033c0:	06300593          	li	a1,99
ffffffffc02033c4:	00003517          	auipc	a0,0x3
ffffffffc02033c8:	24450513          	addi	a0,a0,580 # ffffffffc0206608 <commands+0x1618>
ffffffffc02033cc:	e0bfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==5);
ffffffffc02033d0:	00003697          	auipc	a3,0x3
ffffffffc02033d4:	2f068693          	addi	a3,a3,752 # ffffffffc02066c0 <commands+0x16d0>
ffffffffc02033d8:	00002617          	auipc	a2,0x2
ffffffffc02033dc:	5b060613          	addi	a2,a2,1456 # ffffffffc0205988 <commands+0x998>
ffffffffc02033e0:	06000593          	li	a1,96
ffffffffc02033e4:	00003517          	auipc	a0,0x3
ffffffffc02033e8:	22450513          	addi	a0,a0,548 # ffffffffc0206608 <commands+0x1618>
ffffffffc02033ec:	debfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==5);
ffffffffc02033f0:	00003697          	auipc	a3,0x3
ffffffffc02033f4:	2d068693          	addi	a3,a3,720 # ffffffffc02066c0 <commands+0x16d0>
ffffffffc02033f8:	00002617          	auipc	a2,0x2
ffffffffc02033fc:	59060613          	addi	a2,a2,1424 # ffffffffc0205988 <commands+0x998>
ffffffffc0203400:	05d00593          	li	a1,93
ffffffffc0203404:	00003517          	auipc	a0,0x3
ffffffffc0203408:	20450513          	addi	a0,a0,516 # ffffffffc0206608 <commands+0x1618>
ffffffffc020340c:	dcbfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==4);
ffffffffc0203410:	00003697          	auipc	a3,0x3
ffffffffc0203414:	ff068693          	addi	a3,a3,-16 # ffffffffc0206400 <commands+0x1410>
ffffffffc0203418:	00002617          	auipc	a2,0x2
ffffffffc020341c:	57060613          	addi	a2,a2,1392 # ffffffffc0205988 <commands+0x998>
ffffffffc0203420:	05a00593          	li	a1,90
ffffffffc0203424:	00003517          	auipc	a0,0x3
ffffffffc0203428:	1e450513          	addi	a0,a0,484 # ffffffffc0206608 <commands+0x1618>
ffffffffc020342c:	dabfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==4);
ffffffffc0203430:	00003697          	auipc	a3,0x3
ffffffffc0203434:	fd068693          	addi	a3,a3,-48 # ffffffffc0206400 <commands+0x1410>
ffffffffc0203438:	00002617          	auipc	a2,0x2
ffffffffc020343c:	55060613          	addi	a2,a2,1360 # ffffffffc0205988 <commands+0x998>
ffffffffc0203440:	05700593          	li	a1,87
ffffffffc0203444:	00003517          	auipc	a0,0x3
ffffffffc0203448:	1c450513          	addi	a0,a0,452 # ffffffffc0206608 <commands+0x1618>
ffffffffc020344c:	d8bfc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(pgfault_num==4);
ffffffffc0203450:	00003697          	auipc	a3,0x3
ffffffffc0203454:	fb068693          	addi	a3,a3,-80 # ffffffffc0206400 <commands+0x1410>
ffffffffc0203458:	00002617          	auipc	a2,0x2
ffffffffc020345c:	53060613          	addi	a2,a2,1328 # ffffffffc0205988 <commands+0x998>
ffffffffc0203460:	05400593          	li	a1,84
ffffffffc0203464:	00003517          	auipc	a0,0x3
ffffffffc0203468:	1a450513          	addi	a0,a0,420 # ffffffffc0206608 <commands+0x1618>
ffffffffc020346c:	d6bfc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0203470 <_fifo_swap_out_victim>:
     list_entry_t *head=(list_entry_t*) mm->sm_priv;
ffffffffc0203470:	751c                	ld	a5,40(a0)
{
ffffffffc0203472:	1141                	addi	sp,sp,-16
ffffffffc0203474:	e406                	sd	ra,8(sp)
         assert(head != NULL);
ffffffffc0203476:	cf91                	beqz	a5,ffffffffc0203492 <_fifo_swap_out_victim+0x22>
     assert(in_tick==0);
ffffffffc0203478:	ee0d                	bnez	a2,ffffffffc02034b2 <_fifo_swap_out_victim+0x42>
    return listelm->next;
ffffffffc020347a:	679c                	ld	a5,8(a5)
}
ffffffffc020347c:	60a2                	ld	ra,8(sp)
ffffffffc020347e:	4501                	li	a0,0
    __list_del(listelm->prev, listelm->next);
ffffffffc0203480:	6394                	ld	a3,0(a5)
ffffffffc0203482:	6798                	ld	a4,8(a5)
    *ptr_page = le2page(entry, pra_page_link);
ffffffffc0203484:	fd878793          	addi	a5,a5,-40
    prev->next = next;
ffffffffc0203488:	e698                	sd	a4,8(a3)
    next->prev = prev;
ffffffffc020348a:	e314                	sd	a3,0(a4)
ffffffffc020348c:	e19c                	sd	a5,0(a1)
}
ffffffffc020348e:	0141                	addi	sp,sp,16
ffffffffc0203490:	8082                	ret
         assert(head != NULL);
ffffffffc0203492:	00003697          	auipc	a3,0x3
ffffffffc0203496:	2e668693          	addi	a3,a3,742 # ffffffffc0206778 <commands+0x1788>
ffffffffc020349a:	00002617          	auipc	a2,0x2
ffffffffc020349e:	4ee60613          	addi	a2,a2,1262 # ffffffffc0205988 <commands+0x998>
ffffffffc02034a2:	04100593          	li	a1,65
ffffffffc02034a6:	00003517          	auipc	a0,0x3
ffffffffc02034aa:	16250513          	addi	a0,a0,354 # ffffffffc0206608 <commands+0x1618>
ffffffffc02034ae:	d29fc0ef          	jal	ra,ffffffffc02001d6 <__panic>
     assert(in_tick==0);
ffffffffc02034b2:	00003697          	auipc	a3,0x3
ffffffffc02034b6:	2d668693          	addi	a3,a3,726 # ffffffffc0206788 <commands+0x1798>
ffffffffc02034ba:	00002617          	auipc	a2,0x2
ffffffffc02034be:	4ce60613          	addi	a2,a2,1230 # ffffffffc0205988 <commands+0x998>
ffffffffc02034c2:	04200593          	li	a1,66
ffffffffc02034c6:	00003517          	auipc	a0,0x3
ffffffffc02034ca:	14250513          	addi	a0,a0,322 # ffffffffc0206608 <commands+0x1618>
ffffffffc02034ce:	d09fc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc02034d2 <_fifo_map_swappable>:
    list_entry_t *entry=&(page->pra_page_link);
ffffffffc02034d2:	02860713          	addi	a4,a2,40
    list_entry_t *head=(list_entry_t*) mm->sm_priv;
ffffffffc02034d6:	751c                	ld	a5,40(a0)
    assert(entry != NULL && head != NULL);
ffffffffc02034d8:	cb09                	beqz	a4,ffffffffc02034ea <_fifo_map_swappable+0x18>
ffffffffc02034da:	cb81                	beqz	a5,ffffffffc02034ea <_fifo_map_swappable+0x18>
    __list_add(elm, listelm->prev, listelm);
ffffffffc02034dc:	6394                	ld	a3,0(a5)
    prev->next = next->prev = elm;
ffffffffc02034de:	e398                	sd	a4,0(a5)
}
ffffffffc02034e0:	4501                	li	a0,0
ffffffffc02034e2:	e698                	sd	a4,8(a3)
    elm->next = next;
ffffffffc02034e4:	fa1c                	sd	a5,48(a2)
    elm->prev = prev;
ffffffffc02034e6:	f614                	sd	a3,40(a2)
ffffffffc02034e8:	8082                	ret
{
ffffffffc02034ea:	1141                	addi	sp,sp,-16
    assert(entry != NULL && head != NULL);
ffffffffc02034ec:	00003697          	auipc	a3,0x3
ffffffffc02034f0:	26c68693          	addi	a3,a3,620 # ffffffffc0206758 <commands+0x1768>
ffffffffc02034f4:	00002617          	auipc	a2,0x2
ffffffffc02034f8:	49460613          	addi	a2,a2,1172 # ffffffffc0205988 <commands+0x998>
ffffffffc02034fc:	03200593          	li	a1,50
ffffffffc0203500:	00003517          	auipc	a0,0x3
ffffffffc0203504:	10850513          	addi	a0,a0,264 # ffffffffc0206608 <commands+0x1618>
{
ffffffffc0203508:	e406                	sd	ra,8(sp)
    assert(entry != NULL && head != NULL);
ffffffffc020350a:	ccdfc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc020350e <default_init>:
    elm->prev = elm->next = elm;
ffffffffc020350e:	00012797          	auipc	a5,0x12
ffffffffc0203512:	0ca78793          	addi	a5,a5,202 # ffffffffc02155d8 <free_area>
ffffffffc0203516:	e79c                	sd	a5,8(a5)
ffffffffc0203518:	e39c                	sd	a5,0(a5)
#define nr_free (free_area.nr_free)

static void
default_init(void) {
    list_init(&free_list);
    nr_free = 0;
ffffffffc020351a:	0007a823          	sw	zero,16(a5)
}
ffffffffc020351e:	8082                	ret

ffffffffc0203520 <default_nr_free_pages>:
}

static size_t
default_nr_free_pages(void) {
    return nr_free;
}
ffffffffc0203520:	00012517          	auipc	a0,0x12
ffffffffc0203524:	0c856503          	lwu	a0,200(a0) # ffffffffc02155e8 <free_area+0x10>
ffffffffc0203528:	8082                	ret

ffffffffc020352a <default_check>:
}

// LAB2: below code is used to check the first fit allocation algorithm (your EXERCISE 1) 
// NOTICE: You SHOULD NOT CHANGE basic_check, default_check functions!
static void
default_check(void) {
ffffffffc020352a:	715d                	addi	sp,sp,-80
ffffffffc020352c:	f84a                	sd	s2,48(sp)
    return listelm->next;
ffffffffc020352e:	00012917          	auipc	s2,0x12
ffffffffc0203532:	0aa90913          	addi	s2,s2,170 # ffffffffc02155d8 <free_area>
ffffffffc0203536:	00893783          	ld	a5,8(s2)
ffffffffc020353a:	e486                	sd	ra,72(sp)
ffffffffc020353c:	e0a2                	sd	s0,64(sp)
ffffffffc020353e:	fc26                	sd	s1,56(sp)
ffffffffc0203540:	f44e                	sd	s3,40(sp)
ffffffffc0203542:	f052                	sd	s4,32(sp)
ffffffffc0203544:	ec56                	sd	s5,24(sp)
ffffffffc0203546:	e85a                	sd	s6,16(sp)
ffffffffc0203548:	e45e                	sd	s7,8(sp)
ffffffffc020354a:	e062                	sd	s8,0(sp)
    int count = 0, total = 0;
    list_entry_t *le = &free_list;
    while ((le = list_next(le)) != &free_list) {
ffffffffc020354c:	31278463          	beq	a5,s2,ffffffffc0203854 <default_check+0x32a>
ffffffffc0203550:	ff07b703          	ld	a4,-16(a5)
ffffffffc0203554:	8305                	srli	a4,a4,0x1
        struct Page *p = le2page(le, page_link);
        assert(PageProperty(p));
ffffffffc0203556:	8b05                	andi	a4,a4,1
ffffffffc0203558:	30070263          	beqz	a4,ffffffffc020385c <default_check+0x332>
    int count = 0, total = 0;
ffffffffc020355c:	4401                	li	s0,0
ffffffffc020355e:	4481                	li	s1,0
ffffffffc0203560:	a031                	j	ffffffffc020356c <default_check+0x42>
ffffffffc0203562:	ff07b703          	ld	a4,-16(a5)
        assert(PageProperty(p));
ffffffffc0203566:	8b09                	andi	a4,a4,2
ffffffffc0203568:	2e070a63          	beqz	a4,ffffffffc020385c <default_check+0x332>
        count ++, total += p->property;
ffffffffc020356c:	ff87a703          	lw	a4,-8(a5)
ffffffffc0203570:	679c                	ld	a5,8(a5)
ffffffffc0203572:	2485                	addiw	s1,s1,1
ffffffffc0203574:	9c39                	addw	s0,s0,a4
    while ((le = list_next(le)) != &free_list) {
ffffffffc0203576:	ff2796e3          	bne	a5,s2,ffffffffc0203562 <default_check+0x38>
ffffffffc020357a:	89a2                	mv	s3,s0
    }
    assert(total == nr_free_pages());
ffffffffc020357c:	f0cfd0ef          	jal	ra,ffffffffc0200c88 <nr_free_pages>
ffffffffc0203580:	73351e63          	bne	a0,s3,ffffffffc0203cbc <default_check+0x792>
    assert((p0 = alloc_page()) != NULL);
ffffffffc0203584:	4505                	li	a0,1
ffffffffc0203586:	e34fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc020358a:	8a2a                	mv	s4,a0
ffffffffc020358c:	46050863          	beqz	a0,ffffffffc02039fc <default_check+0x4d2>
    assert((p1 = alloc_page()) != NULL);
ffffffffc0203590:	4505                	li	a0,1
ffffffffc0203592:	e28fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0203596:	89aa                	mv	s3,a0
ffffffffc0203598:	74050263          	beqz	a0,ffffffffc0203cdc <default_check+0x7b2>
    assert((p2 = alloc_page()) != NULL);
ffffffffc020359c:	4505                	li	a0,1
ffffffffc020359e:	e1cfd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02035a2:	8aaa                	mv	s5,a0
ffffffffc02035a4:	4c050c63          	beqz	a0,ffffffffc0203a7c <default_check+0x552>
    assert(p0 != p1 && p0 != p2 && p1 != p2);
ffffffffc02035a8:	2d3a0a63          	beq	s4,s3,ffffffffc020387c <default_check+0x352>
ffffffffc02035ac:	2caa0863          	beq	s4,a0,ffffffffc020387c <default_check+0x352>
ffffffffc02035b0:	2ca98663          	beq	s3,a0,ffffffffc020387c <default_check+0x352>
    assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0);
ffffffffc02035b4:	000a2783          	lw	a5,0(s4)
ffffffffc02035b8:	2e079263          	bnez	a5,ffffffffc020389c <default_check+0x372>
ffffffffc02035bc:	0009a783          	lw	a5,0(s3)
ffffffffc02035c0:	2c079e63          	bnez	a5,ffffffffc020389c <default_check+0x372>
ffffffffc02035c4:	411c                	lw	a5,0(a0)
ffffffffc02035c6:	2c079b63          	bnez	a5,ffffffffc020389c <default_check+0x372>
    return page - pages + nbase;
ffffffffc02035ca:	00012797          	auipc	a5,0x12
ffffffffc02035ce:	f2678793          	addi	a5,a5,-218 # ffffffffc02154f0 <pages>
ffffffffc02035d2:	639c                	ld	a5,0(a5)
ffffffffc02035d4:	00004717          	auipc	a4,0x4
ffffffffc02035d8:	9cc70713          	addi	a4,a4,-1588 # ffffffffc0206fa0 <nbase>
ffffffffc02035dc:	6310                	ld	a2,0(a4)
    assert(page2pa(p0) < npage * PGSIZE);
ffffffffc02035de:	00012717          	auipc	a4,0x12
ffffffffc02035e2:	eaa70713          	addi	a4,a4,-342 # ffffffffc0215488 <npage>
ffffffffc02035e6:	6314                	ld	a3,0(a4)
ffffffffc02035e8:	40fa0733          	sub	a4,s4,a5
ffffffffc02035ec:	8719                	srai	a4,a4,0x6
ffffffffc02035ee:	9732                	add	a4,a4,a2
ffffffffc02035f0:	06b2                	slli	a3,a3,0xc
    return page2ppn(page) << PGSHIFT;
ffffffffc02035f2:	0732                	slli	a4,a4,0xc
ffffffffc02035f4:	2cd77463          	bleu	a3,a4,ffffffffc02038bc <default_check+0x392>
    return page - pages + nbase;
ffffffffc02035f8:	40f98733          	sub	a4,s3,a5
ffffffffc02035fc:	8719                	srai	a4,a4,0x6
ffffffffc02035fe:	9732                	add	a4,a4,a2
    return page2ppn(page) << PGSHIFT;
ffffffffc0203600:	0732                	slli	a4,a4,0xc
    assert(page2pa(p1) < npage * PGSIZE);
ffffffffc0203602:	4ed77d63          	bleu	a3,a4,ffffffffc0203afc <default_check+0x5d2>
    return page - pages + nbase;
ffffffffc0203606:	40f507b3          	sub	a5,a0,a5
ffffffffc020360a:	8799                	srai	a5,a5,0x6
ffffffffc020360c:	97b2                	add	a5,a5,a2
    return page2ppn(page) << PGSHIFT;
ffffffffc020360e:	07b2                	slli	a5,a5,0xc
    assert(page2pa(p2) < npage * PGSIZE);
ffffffffc0203610:	34d7f663          	bleu	a3,a5,ffffffffc020395c <default_check+0x432>
    assert(alloc_page() == NULL);
ffffffffc0203614:	4505                	li	a0,1
    list_entry_t free_list_store = free_list;
ffffffffc0203616:	00093c03          	ld	s8,0(s2)
ffffffffc020361a:	00893b83          	ld	s7,8(s2)
    unsigned int nr_free_store = nr_free;
ffffffffc020361e:	01092b03          	lw	s6,16(s2)
    elm->prev = elm->next = elm;
ffffffffc0203622:	00012797          	auipc	a5,0x12
ffffffffc0203626:	fb27bf23          	sd	s2,-66(a5) # ffffffffc02155e0 <free_area+0x8>
ffffffffc020362a:	00012797          	auipc	a5,0x12
ffffffffc020362e:	fb27b723          	sd	s2,-82(a5) # ffffffffc02155d8 <free_area>
    nr_free = 0;
ffffffffc0203632:	00012797          	auipc	a5,0x12
ffffffffc0203636:	fa07ab23          	sw	zero,-74(a5) # ffffffffc02155e8 <free_area+0x10>
    assert(alloc_page() == NULL);
ffffffffc020363a:	d80fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc020363e:	2e051f63          	bnez	a0,ffffffffc020393c <default_check+0x412>
    free_page(p0);
ffffffffc0203642:	4585                	li	a1,1
ffffffffc0203644:	8552                	mv	a0,s4
ffffffffc0203646:	dfcfd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    free_page(p1);
ffffffffc020364a:	4585                	li	a1,1
ffffffffc020364c:	854e                	mv	a0,s3
ffffffffc020364e:	df4fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    free_page(p2);
ffffffffc0203652:	4585                	li	a1,1
ffffffffc0203654:	8556                	mv	a0,s5
ffffffffc0203656:	decfd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    assert(nr_free == 3);
ffffffffc020365a:	01092703          	lw	a4,16(s2)
ffffffffc020365e:	478d                	li	a5,3
ffffffffc0203660:	2af71e63          	bne	a4,a5,ffffffffc020391c <default_check+0x3f2>
    assert((p0 = alloc_page()) != NULL);
ffffffffc0203664:	4505                	li	a0,1
ffffffffc0203666:	d54fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc020366a:	89aa                	mv	s3,a0
ffffffffc020366c:	28050863          	beqz	a0,ffffffffc02038fc <default_check+0x3d2>
    assert((p1 = alloc_page()) != NULL);
ffffffffc0203670:	4505                	li	a0,1
ffffffffc0203672:	d48fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0203676:	8aaa                	mv	s5,a0
ffffffffc0203678:	3e050263          	beqz	a0,ffffffffc0203a5c <default_check+0x532>
    assert((p2 = alloc_page()) != NULL);
ffffffffc020367c:	4505                	li	a0,1
ffffffffc020367e:	d3cfd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0203682:	8a2a                	mv	s4,a0
ffffffffc0203684:	3a050c63          	beqz	a0,ffffffffc0203a3c <default_check+0x512>
    assert(alloc_page() == NULL);
ffffffffc0203688:	4505                	li	a0,1
ffffffffc020368a:	d30fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc020368e:	38051763          	bnez	a0,ffffffffc0203a1c <default_check+0x4f2>
    free_page(p0);
ffffffffc0203692:	4585                	li	a1,1
ffffffffc0203694:	854e                	mv	a0,s3
ffffffffc0203696:	dacfd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    assert(!list_empty(&free_list));
ffffffffc020369a:	00893783          	ld	a5,8(s2)
ffffffffc020369e:	23278f63          	beq	a5,s2,ffffffffc02038dc <default_check+0x3b2>
    assert((p = alloc_page()) == p0);
ffffffffc02036a2:	4505                	li	a0,1
ffffffffc02036a4:	d16fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02036a8:	32a99a63          	bne	s3,a0,ffffffffc02039dc <default_check+0x4b2>
    assert(alloc_page() == NULL);
ffffffffc02036ac:	4505                	li	a0,1
ffffffffc02036ae:	d0cfd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02036b2:	30051563          	bnez	a0,ffffffffc02039bc <default_check+0x492>
    assert(nr_free == 0);
ffffffffc02036b6:	01092783          	lw	a5,16(s2)
ffffffffc02036ba:	2e079163          	bnez	a5,ffffffffc020399c <default_check+0x472>
    free_page(p);
ffffffffc02036be:	854e                	mv	a0,s3
ffffffffc02036c0:	4585                	li	a1,1
    free_list = free_list_store;
ffffffffc02036c2:	00012797          	auipc	a5,0x12
ffffffffc02036c6:	f187bb23          	sd	s8,-234(a5) # ffffffffc02155d8 <free_area>
ffffffffc02036ca:	00012797          	auipc	a5,0x12
ffffffffc02036ce:	f177bb23          	sd	s7,-234(a5) # ffffffffc02155e0 <free_area+0x8>
    nr_free = nr_free_store;
ffffffffc02036d2:	00012797          	auipc	a5,0x12
ffffffffc02036d6:	f167ab23          	sw	s6,-234(a5) # ffffffffc02155e8 <free_area+0x10>
    free_page(p);
ffffffffc02036da:	d68fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    free_page(p1);
ffffffffc02036de:	4585                	li	a1,1
ffffffffc02036e0:	8556                	mv	a0,s5
ffffffffc02036e2:	d60fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    free_page(p2);
ffffffffc02036e6:	4585                	li	a1,1
ffffffffc02036e8:	8552                	mv	a0,s4
ffffffffc02036ea:	d58fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>

    basic_check();

    struct Page *p0 = alloc_pages(5), *p1, *p2;
ffffffffc02036ee:	4515                	li	a0,5
ffffffffc02036f0:	ccafd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02036f4:	89aa                	mv	s3,a0
    assert(p0 != NULL);
ffffffffc02036f6:	28050363          	beqz	a0,ffffffffc020397c <default_check+0x452>
ffffffffc02036fa:	651c                	ld	a5,8(a0)
ffffffffc02036fc:	8385                	srli	a5,a5,0x1
    assert(!PageProperty(p0));
ffffffffc02036fe:	8b85                	andi	a5,a5,1
ffffffffc0203700:	54079e63          	bnez	a5,ffffffffc0203c5c <default_check+0x732>

    list_entry_t free_list_store = free_list;
    list_init(&free_list);
    assert(list_empty(&free_list));
    assert(alloc_page() == NULL);
ffffffffc0203704:	4505                	li	a0,1
    list_entry_t free_list_store = free_list;
ffffffffc0203706:	00093b03          	ld	s6,0(s2)
ffffffffc020370a:	00893a83          	ld	s5,8(s2)
ffffffffc020370e:	00012797          	auipc	a5,0x12
ffffffffc0203712:	ed27b523          	sd	s2,-310(a5) # ffffffffc02155d8 <free_area>
ffffffffc0203716:	00012797          	auipc	a5,0x12
ffffffffc020371a:	ed27b523          	sd	s2,-310(a5) # ffffffffc02155e0 <free_area+0x8>
    assert(alloc_page() == NULL);
ffffffffc020371e:	c9cfd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0203722:	50051d63          	bnez	a0,ffffffffc0203c3c <default_check+0x712>

    unsigned int nr_free_store = nr_free;
    nr_free = 0;

    free_pages(p0 + 2, 3);
ffffffffc0203726:	08098a13          	addi	s4,s3,128
ffffffffc020372a:	8552                	mv	a0,s4
ffffffffc020372c:	458d                	li	a1,3
    unsigned int nr_free_store = nr_free;
ffffffffc020372e:	01092b83          	lw	s7,16(s2)
    nr_free = 0;
ffffffffc0203732:	00012797          	auipc	a5,0x12
ffffffffc0203736:	ea07ab23          	sw	zero,-330(a5) # ffffffffc02155e8 <free_area+0x10>
    free_pages(p0 + 2, 3);
ffffffffc020373a:	d08fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    assert(alloc_pages(4) == NULL);
ffffffffc020373e:	4511                	li	a0,4
ffffffffc0203740:	c7afd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0203744:	4c051c63          	bnez	a0,ffffffffc0203c1c <default_check+0x6f2>
ffffffffc0203748:	0889b783          	ld	a5,136(s3)
ffffffffc020374c:	8385                	srli	a5,a5,0x1
    assert(PageProperty(p0 + 2) && p0[2].property == 3);
ffffffffc020374e:	8b85                	andi	a5,a5,1
ffffffffc0203750:	4a078663          	beqz	a5,ffffffffc0203bfc <default_check+0x6d2>
ffffffffc0203754:	0909a703          	lw	a4,144(s3)
ffffffffc0203758:	478d                	li	a5,3
ffffffffc020375a:	4af71163          	bne	a4,a5,ffffffffc0203bfc <default_check+0x6d2>
    assert((p1 = alloc_pages(3)) != NULL);
ffffffffc020375e:	450d                	li	a0,3
ffffffffc0203760:	c5afd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0203764:	8c2a                	mv	s8,a0
ffffffffc0203766:	46050b63          	beqz	a0,ffffffffc0203bdc <default_check+0x6b2>
    assert(alloc_page() == NULL);
ffffffffc020376a:	4505                	li	a0,1
ffffffffc020376c:	c4efd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc0203770:	44051663          	bnez	a0,ffffffffc0203bbc <default_check+0x692>
    assert(p0 + 2 == p1);
ffffffffc0203774:	438a1463          	bne	s4,s8,ffffffffc0203b9c <default_check+0x672>

    p2 = p0 + 1;
    free_page(p0);
ffffffffc0203778:	4585                	li	a1,1
ffffffffc020377a:	854e                	mv	a0,s3
ffffffffc020377c:	cc6fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    free_pages(p1, 3);
ffffffffc0203780:	458d                	li	a1,3
ffffffffc0203782:	8552                	mv	a0,s4
ffffffffc0203784:	cbefd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
ffffffffc0203788:	0089b783          	ld	a5,8(s3)
    p2 = p0 + 1;
ffffffffc020378c:	04098c13          	addi	s8,s3,64
ffffffffc0203790:	8385                	srli	a5,a5,0x1
    assert(PageProperty(p0) && p0->property == 1);
ffffffffc0203792:	8b85                	andi	a5,a5,1
ffffffffc0203794:	3e078463          	beqz	a5,ffffffffc0203b7c <default_check+0x652>
ffffffffc0203798:	0109a703          	lw	a4,16(s3)
ffffffffc020379c:	4785                	li	a5,1
ffffffffc020379e:	3cf71f63          	bne	a4,a5,ffffffffc0203b7c <default_check+0x652>
ffffffffc02037a2:	008a3783          	ld	a5,8(s4)
ffffffffc02037a6:	8385                	srli	a5,a5,0x1
    assert(PageProperty(p1) && p1->property == 3);
ffffffffc02037a8:	8b85                	andi	a5,a5,1
ffffffffc02037aa:	3a078963          	beqz	a5,ffffffffc0203b5c <default_check+0x632>
ffffffffc02037ae:	010a2703          	lw	a4,16(s4)
ffffffffc02037b2:	478d                	li	a5,3
ffffffffc02037b4:	3af71463          	bne	a4,a5,ffffffffc0203b5c <default_check+0x632>

    assert((p0 = alloc_page()) == p2 - 1);
ffffffffc02037b8:	4505                	li	a0,1
ffffffffc02037ba:	c00fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02037be:	36a99f63          	bne	s3,a0,ffffffffc0203b3c <default_check+0x612>
    free_page(p0);
ffffffffc02037c2:	4585                	li	a1,1
ffffffffc02037c4:	c7efd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    assert((p0 = alloc_pages(2)) == p2 + 1);
ffffffffc02037c8:	4509                	li	a0,2
ffffffffc02037ca:	bf0fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02037ce:	34aa1763          	bne	s4,a0,ffffffffc0203b1c <default_check+0x5f2>

    free_pages(p0, 2);
ffffffffc02037d2:	4589                	li	a1,2
ffffffffc02037d4:	c6efd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    free_page(p2);
ffffffffc02037d8:	4585                	li	a1,1
ffffffffc02037da:	8562                	mv	a0,s8
ffffffffc02037dc:	c66fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>

    assert((p0 = alloc_pages(5)) != NULL);
ffffffffc02037e0:	4515                	li	a0,5
ffffffffc02037e2:	bd8fd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02037e6:	89aa                	mv	s3,a0
ffffffffc02037e8:	48050a63          	beqz	a0,ffffffffc0203c7c <default_check+0x752>
    assert(alloc_page() == NULL);
ffffffffc02037ec:	4505                	li	a0,1
ffffffffc02037ee:	bccfd0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
ffffffffc02037f2:	2e051563          	bnez	a0,ffffffffc0203adc <default_check+0x5b2>

    assert(nr_free == 0);
ffffffffc02037f6:	01092783          	lw	a5,16(s2)
ffffffffc02037fa:	2c079163          	bnez	a5,ffffffffc0203abc <default_check+0x592>
    nr_free = nr_free_store;

    free_list = free_list_store;
    free_pages(p0, 5);
ffffffffc02037fe:	4595                	li	a1,5
ffffffffc0203800:	854e                	mv	a0,s3
    nr_free = nr_free_store;
ffffffffc0203802:	00012797          	auipc	a5,0x12
ffffffffc0203806:	df77a323          	sw	s7,-538(a5) # ffffffffc02155e8 <free_area+0x10>
    free_list = free_list_store;
ffffffffc020380a:	00012797          	auipc	a5,0x12
ffffffffc020380e:	dd67b723          	sd	s6,-562(a5) # ffffffffc02155d8 <free_area>
ffffffffc0203812:	00012797          	auipc	a5,0x12
ffffffffc0203816:	dd57b723          	sd	s5,-562(a5) # ffffffffc02155e0 <free_area+0x8>
    free_pages(p0, 5);
ffffffffc020381a:	c28fd0ef          	jal	ra,ffffffffc0200c42 <free_pages>
    return listelm->next;
ffffffffc020381e:	00893783          	ld	a5,8(s2)

    le = &free_list;
    while ((le = list_next(le)) != &free_list) {
ffffffffc0203822:	01278963          	beq	a5,s2,ffffffffc0203834 <default_check+0x30a>
        struct Page *p = le2page(le, page_link);
        count --, total -= p->property;
ffffffffc0203826:	ff87a703          	lw	a4,-8(a5)
ffffffffc020382a:	679c                	ld	a5,8(a5)
ffffffffc020382c:	34fd                	addiw	s1,s1,-1
ffffffffc020382e:	9c19                	subw	s0,s0,a4
    while ((le = list_next(le)) != &free_list) {
ffffffffc0203830:	ff279be3          	bne	a5,s2,ffffffffc0203826 <default_check+0x2fc>
    }
    assert(count == 0);
ffffffffc0203834:	26049463          	bnez	s1,ffffffffc0203a9c <default_check+0x572>
    assert(total == 0);
ffffffffc0203838:	46041263          	bnez	s0,ffffffffc0203c9c <default_check+0x772>
}
ffffffffc020383c:	60a6                	ld	ra,72(sp)
ffffffffc020383e:	6406                	ld	s0,64(sp)
ffffffffc0203840:	74e2                	ld	s1,56(sp)
ffffffffc0203842:	7942                	ld	s2,48(sp)
ffffffffc0203844:	79a2                	ld	s3,40(sp)
ffffffffc0203846:	7a02                	ld	s4,32(sp)
ffffffffc0203848:	6ae2                	ld	s5,24(sp)
ffffffffc020384a:	6b42                	ld	s6,16(sp)
ffffffffc020384c:	6ba2                	ld	s7,8(sp)
ffffffffc020384e:	6c02                	ld	s8,0(sp)
ffffffffc0203850:	6161                	addi	sp,sp,80
ffffffffc0203852:	8082                	ret
    while ((le = list_next(le)) != &free_list) {
ffffffffc0203854:	4981                	li	s3,0
    int count = 0, total = 0;
ffffffffc0203856:	4401                	li	s0,0
ffffffffc0203858:	4481                	li	s1,0
ffffffffc020385a:	b30d                	j	ffffffffc020357c <default_check+0x52>
        assert(PageProperty(p));
ffffffffc020385c:	00003697          	auipc	a3,0x3
ffffffffc0203860:	a0468693          	addi	a3,a3,-1532 # ffffffffc0206260 <commands+0x1270>
ffffffffc0203864:	00002617          	auipc	a2,0x2
ffffffffc0203868:	12460613          	addi	a2,a2,292 # ffffffffc0205988 <commands+0x998>
ffffffffc020386c:	0f000593          	li	a1,240
ffffffffc0203870:	00003517          	auipc	a0,0x3
ffffffffc0203874:	f4050513          	addi	a0,a0,-192 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203878:	95ffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(p0 != p1 && p0 != p2 && p1 != p2);
ffffffffc020387c:	00003697          	auipc	a3,0x3
ffffffffc0203880:	fac68693          	addi	a3,a3,-84 # ffffffffc0206828 <commands+0x1838>
ffffffffc0203884:	00002617          	auipc	a2,0x2
ffffffffc0203888:	10460613          	addi	a2,a2,260 # ffffffffc0205988 <commands+0x998>
ffffffffc020388c:	0bd00593          	li	a1,189
ffffffffc0203890:	00003517          	auipc	a0,0x3
ffffffffc0203894:	f2050513          	addi	a0,a0,-224 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203898:	93ffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0);
ffffffffc020389c:	00003697          	auipc	a3,0x3
ffffffffc02038a0:	fb468693          	addi	a3,a3,-76 # ffffffffc0206850 <commands+0x1860>
ffffffffc02038a4:	00002617          	auipc	a2,0x2
ffffffffc02038a8:	0e460613          	addi	a2,a2,228 # ffffffffc0205988 <commands+0x998>
ffffffffc02038ac:	0be00593          	li	a1,190
ffffffffc02038b0:	00003517          	auipc	a0,0x3
ffffffffc02038b4:	f0050513          	addi	a0,a0,-256 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc02038b8:	91ffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page2pa(p0) < npage * PGSIZE);
ffffffffc02038bc:	00003697          	auipc	a3,0x3
ffffffffc02038c0:	fd468693          	addi	a3,a3,-44 # ffffffffc0206890 <commands+0x18a0>
ffffffffc02038c4:	00002617          	auipc	a2,0x2
ffffffffc02038c8:	0c460613          	addi	a2,a2,196 # ffffffffc0205988 <commands+0x998>
ffffffffc02038cc:	0c000593          	li	a1,192
ffffffffc02038d0:	00003517          	auipc	a0,0x3
ffffffffc02038d4:	ee050513          	addi	a0,a0,-288 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc02038d8:	8fffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(!list_empty(&free_list));
ffffffffc02038dc:	00003697          	auipc	a3,0x3
ffffffffc02038e0:	03c68693          	addi	a3,a3,60 # ffffffffc0206918 <commands+0x1928>
ffffffffc02038e4:	00002617          	auipc	a2,0x2
ffffffffc02038e8:	0a460613          	addi	a2,a2,164 # ffffffffc0205988 <commands+0x998>
ffffffffc02038ec:	0d900593          	li	a1,217
ffffffffc02038f0:	00003517          	auipc	a0,0x3
ffffffffc02038f4:	ec050513          	addi	a0,a0,-320 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc02038f8:	8dffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p0 = alloc_page()) != NULL);
ffffffffc02038fc:	00003697          	auipc	a3,0x3
ffffffffc0203900:	ecc68693          	addi	a3,a3,-308 # ffffffffc02067c8 <commands+0x17d8>
ffffffffc0203904:	00002617          	auipc	a2,0x2
ffffffffc0203908:	08460613          	addi	a2,a2,132 # ffffffffc0205988 <commands+0x998>
ffffffffc020390c:	0d200593          	li	a1,210
ffffffffc0203910:	00003517          	auipc	a0,0x3
ffffffffc0203914:	ea050513          	addi	a0,a0,-352 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203918:	8bffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(nr_free == 3);
ffffffffc020391c:	00003697          	auipc	a3,0x3
ffffffffc0203920:	fec68693          	addi	a3,a3,-20 # ffffffffc0206908 <commands+0x1918>
ffffffffc0203924:	00002617          	auipc	a2,0x2
ffffffffc0203928:	06460613          	addi	a2,a2,100 # ffffffffc0205988 <commands+0x998>
ffffffffc020392c:	0d000593          	li	a1,208
ffffffffc0203930:	00003517          	auipc	a0,0x3
ffffffffc0203934:	e8050513          	addi	a0,a0,-384 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203938:	89ffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(alloc_page() == NULL);
ffffffffc020393c:	00003697          	auipc	a3,0x3
ffffffffc0203940:	fb468693          	addi	a3,a3,-76 # ffffffffc02068f0 <commands+0x1900>
ffffffffc0203944:	00002617          	auipc	a2,0x2
ffffffffc0203948:	04460613          	addi	a2,a2,68 # ffffffffc0205988 <commands+0x998>
ffffffffc020394c:	0cb00593          	li	a1,203
ffffffffc0203950:	00003517          	auipc	a0,0x3
ffffffffc0203954:	e6050513          	addi	a0,a0,-416 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203958:	87ffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page2pa(p2) < npage * PGSIZE);
ffffffffc020395c:	00003697          	auipc	a3,0x3
ffffffffc0203960:	f7468693          	addi	a3,a3,-140 # ffffffffc02068d0 <commands+0x18e0>
ffffffffc0203964:	00002617          	auipc	a2,0x2
ffffffffc0203968:	02460613          	addi	a2,a2,36 # ffffffffc0205988 <commands+0x998>
ffffffffc020396c:	0c200593          	li	a1,194
ffffffffc0203970:	00003517          	auipc	a0,0x3
ffffffffc0203974:	e4050513          	addi	a0,a0,-448 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203978:	85ffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(p0 != NULL);
ffffffffc020397c:	00003697          	auipc	a3,0x3
ffffffffc0203980:	fd468693          	addi	a3,a3,-44 # ffffffffc0206950 <commands+0x1960>
ffffffffc0203984:	00002617          	auipc	a2,0x2
ffffffffc0203988:	00460613          	addi	a2,a2,4 # ffffffffc0205988 <commands+0x998>
ffffffffc020398c:	0f800593          	li	a1,248
ffffffffc0203990:	00003517          	auipc	a0,0x3
ffffffffc0203994:	e2050513          	addi	a0,a0,-480 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203998:	83ffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(nr_free == 0);
ffffffffc020399c:	00003697          	auipc	a3,0x3
ffffffffc02039a0:	a7468693          	addi	a3,a3,-1420 # ffffffffc0206410 <commands+0x1420>
ffffffffc02039a4:	00002617          	auipc	a2,0x2
ffffffffc02039a8:	fe460613          	addi	a2,a2,-28 # ffffffffc0205988 <commands+0x998>
ffffffffc02039ac:	0df00593          	li	a1,223
ffffffffc02039b0:	00003517          	auipc	a0,0x3
ffffffffc02039b4:	e0050513          	addi	a0,a0,-512 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc02039b8:	81ffc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(alloc_page() == NULL);
ffffffffc02039bc:	00003697          	auipc	a3,0x3
ffffffffc02039c0:	f3468693          	addi	a3,a3,-204 # ffffffffc02068f0 <commands+0x1900>
ffffffffc02039c4:	00002617          	auipc	a2,0x2
ffffffffc02039c8:	fc460613          	addi	a2,a2,-60 # ffffffffc0205988 <commands+0x998>
ffffffffc02039cc:	0dd00593          	li	a1,221
ffffffffc02039d0:	00003517          	auipc	a0,0x3
ffffffffc02039d4:	de050513          	addi	a0,a0,-544 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc02039d8:	ffefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p = alloc_page()) == p0);
ffffffffc02039dc:	00003697          	auipc	a3,0x3
ffffffffc02039e0:	f5468693          	addi	a3,a3,-172 # ffffffffc0206930 <commands+0x1940>
ffffffffc02039e4:	00002617          	auipc	a2,0x2
ffffffffc02039e8:	fa460613          	addi	a2,a2,-92 # ffffffffc0205988 <commands+0x998>
ffffffffc02039ec:	0dc00593          	li	a1,220
ffffffffc02039f0:	00003517          	auipc	a0,0x3
ffffffffc02039f4:	dc050513          	addi	a0,a0,-576 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc02039f8:	fdefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p0 = alloc_page()) != NULL);
ffffffffc02039fc:	00003697          	auipc	a3,0x3
ffffffffc0203a00:	dcc68693          	addi	a3,a3,-564 # ffffffffc02067c8 <commands+0x17d8>
ffffffffc0203a04:	00002617          	auipc	a2,0x2
ffffffffc0203a08:	f8460613          	addi	a2,a2,-124 # ffffffffc0205988 <commands+0x998>
ffffffffc0203a0c:	0b900593          	li	a1,185
ffffffffc0203a10:	00003517          	auipc	a0,0x3
ffffffffc0203a14:	da050513          	addi	a0,a0,-608 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203a18:	fbefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(alloc_page() == NULL);
ffffffffc0203a1c:	00003697          	auipc	a3,0x3
ffffffffc0203a20:	ed468693          	addi	a3,a3,-300 # ffffffffc02068f0 <commands+0x1900>
ffffffffc0203a24:	00002617          	auipc	a2,0x2
ffffffffc0203a28:	f6460613          	addi	a2,a2,-156 # ffffffffc0205988 <commands+0x998>
ffffffffc0203a2c:	0d600593          	li	a1,214
ffffffffc0203a30:	00003517          	auipc	a0,0x3
ffffffffc0203a34:	d8050513          	addi	a0,a0,-640 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203a38:	f9efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p2 = alloc_page()) != NULL);
ffffffffc0203a3c:	00003697          	auipc	a3,0x3
ffffffffc0203a40:	dcc68693          	addi	a3,a3,-564 # ffffffffc0206808 <commands+0x1818>
ffffffffc0203a44:	00002617          	auipc	a2,0x2
ffffffffc0203a48:	f4460613          	addi	a2,a2,-188 # ffffffffc0205988 <commands+0x998>
ffffffffc0203a4c:	0d400593          	li	a1,212
ffffffffc0203a50:	00003517          	auipc	a0,0x3
ffffffffc0203a54:	d6050513          	addi	a0,a0,-672 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203a58:	f7efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p1 = alloc_page()) != NULL);
ffffffffc0203a5c:	00003697          	auipc	a3,0x3
ffffffffc0203a60:	d8c68693          	addi	a3,a3,-628 # ffffffffc02067e8 <commands+0x17f8>
ffffffffc0203a64:	00002617          	auipc	a2,0x2
ffffffffc0203a68:	f2460613          	addi	a2,a2,-220 # ffffffffc0205988 <commands+0x998>
ffffffffc0203a6c:	0d300593          	li	a1,211
ffffffffc0203a70:	00003517          	auipc	a0,0x3
ffffffffc0203a74:	d4050513          	addi	a0,a0,-704 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203a78:	f5efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p2 = alloc_page()) != NULL);
ffffffffc0203a7c:	00003697          	auipc	a3,0x3
ffffffffc0203a80:	d8c68693          	addi	a3,a3,-628 # ffffffffc0206808 <commands+0x1818>
ffffffffc0203a84:	00002617          	auipc	a2,0x2
ffffffffc0203a88:	f0460613          	addi	a2,a2,-252 # ffffffffc0205988 <commands+0x998>
ffffffffc0203a8c:	0bb00593          	li	a1,187
ffffffffc0203a90:	00003517          	auipc	a0,0x3
ffffffffc0203a94:	d2050513          	addi	a0,a0,-736 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203a98:	f3efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(count == 0);
ffffffffc0203a9c:	00003697          	auipc	a3,0x3
ffffffffc0203aa0:	00468693          	addi	a3,a3,4 # ffffffffc0206aa0 <commands+0x1ab0>
ffffffffc0203aa4:	00002617          	auipc	a2,0x2
ffffffffc0203aa8:	ee460613          	addi	a2,a2,-284 # ffffffffc0205988 <commands+0x998>
ffffffffc0203aac:	12500593          	li	a1,293
ffffffffc0203ab0:	00003517          	auipc	a0,0x3
ffffffffc0203ab4:	d0050513          	addi	a0,a0,-768 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203ab8:	f1efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(nr_free == 0);
ffffffffc0203abc:	00003697          	auipc	a3,0x3
ffffffffc0203ac0:	95468693          	addi	a3,a3,-1708 # ffffffffc0206410 <commands+0x1420>
ffffffffc0203ac4:	00002617          	auipc	a2,0x2
ffffffffc0203ac8:	ec460613          	addi	a2,a2,-316 # ffffffffc0205988 <commands+0x998>
ffffffffc0203acc:	11a00593          	li	a1,282
ffffffffc0203ad0:	00003517          	auipc	a0,0x3
ffffffffc0203ad4:	ce050513          	addi	a0,a0,-800 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203ad8:	efefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(alloc_page() == NULL);
ffffffffc0203adc:	00003697          	auipc	a3,0x3
ffffffffc0203ae0:	e1468693          	addi	a3,a3,-492 # ffffffffc02068f0 <commands+0x1900>
ffffffffc0203ae4:	00002617          	auipc	a2,0x2
ffffffffc0203ae8:	ea460613          	addi	a2,a2,-348 # ffffffffc0205988 <commands+0x998>
ffffffffc0203aec:	11800593          	li	a1,280
ffffffffc0203af0:	00003517          	auipc	a0,0x3
ffffffffc0203af4:	cc050513          	addi	a0,a0,-832 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203af8:	edefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(page2pa(p1) < npage * PGSIZE);
ffffffffc0203afc:	00003697          	auipc	a3,0x3
ffffffffc0203b00:	db468693          	addi	a3,a3,-588 # ffffffffc02068b0 <commands+0x18c0>
ffffffffc0203b04:	00002617          	auipc	a2,0x2
ffffffffc0203b08:	e8460613          	addi	a2,a2,-380 # ffffffffc0205988 <commands+0x998>
ffffffffc0203b0c:	0c100593          	li	a1,193
ffffffffc0203b10:	00003517          	auipc	a0,0x3
ffffffffc0203b14:	ca050513          	addi	a0,a0,-864 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203b18:	ebefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p0 = alloc_pages(2)) == p2 + 1);
ffffffffc0203b1c:	00003697          	auipc	a3,0x3
ffffffffc0203b20:	f4468693          	addi	a3,a3,-188 # ffffffffc0206a60 <commands+0x1a70>
ffffffffc0203b24:	00002617          	auipc	a2,0x2
ffffffffc0203b28:	e6460613          	addi	a2,a2,-412 # ffffffffc0205988 <commands+0x998>
ffffffffc0203b2c:	11200593          	li	a1,274
ffffffffc0203b30:	00003517          	auipc	a0,0x3
ffffffffc0203b34:	c8050513          	addi	a0,a0,-896 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203b38:	e9efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p0 = alloc_page()) == p2 - 1);
ffffffffc0203b3c:	00003697          	auipc	a3,0x3
ffffffffc0203b40:	f0468693          	addi	a3,a3,-252 # ffffffffc0206a40 <commands+0x1a50>
ffffffffc0203b44:	00002617          	auipc	a2,0x2
ffffffffc0203b48:	e4460613          	addi	a2,a2,-444 # ffffffffc0205988 <commands+0x998>
ffffffffc0203b4c:	11000593          	li	a1,272
ffffffffc0203b50:	00003517          	auipc	a0,0x3
ffffffffc0203b54:	c6050513          	addi	a0,a0,-928 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203b58:	e7efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(PageProperty(p1) && p1->property == 3);
ffffffffc0203b5c:	00003697          	auipc	a3,0x3
ffffffffc0203b60:	ebc68693          	addi	a3,a3,-324 # ffffffffc0206a18 <commands+0x1a28>
ffffffffc0203b64:	00002617          	auipc	a2,0x2
ffffffffc0203b68:	e2460613          	addi	a2,a2,-476 # ffffffffc0205988 <commands+0x998>
ffffffffc0203b6c:	10e00593          	li	a1,270
ffffffffc0203b70:	00003517          	auipc	a0,0x3
ffffffffc0203b74:	c4050513          	addi	a0,a0,-960 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203b78:	e5efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(PageProperty(p0) && p0->property == 1);
ffffffffc0203b7c:	00003697          	auipc	a3,0x3
ffffffffc0203b80:	e7468693          	addi	a3,a3,-396 # ffffffffc02069f0 <commands+0x1a00>
ffffffffc0203b84:	00002617          	auipc	a2,0x2
ffffffffc0203b88:	e0460613          	addi	a2,a2,-508 # ffffffffc0205988 <commands+0x998>
ffffffffc0203b8c:	10d00593          	li	a1,269
ffffffffc0203b90:	00003517          	auipc	a0,0x3
ffffffffc0203b94:	c2050513          	addi	a0,a0,-992 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203b98:	e3efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(p0 + 2 == p1);
ffffffffc0203b9c:	00003697          	auipc	a3,0x3
ffffffffc0203ba0:	e4468693          	addi	a3,a3,-444 # ffffffffc02069e0 <commands+0x19f0>
ffffffffc0203ba4:	00002617          	auipc	a2,0x2
ffffffffc0203ba8:	de460613          	addi	a2,a2,-540 # ffffffffc0205988 <commands+0x998>
ffffffffc0203bac:	10800593          	li	a1,264
ffffffffc0203bb0:	00003517          	auipc	a0,0x3
ffffffffc0203bb4:	c0050513          	addi	a0,a0,-1024 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203bb8:	e1efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(alloc_page() == NULL);
ffffffffc0203bbc:	00003697          	auipc	a3,0x3
ffffffffc0203bc0:	d3468693          	addi	a3,a3,-716 # ffffffffc02068f0 <commands+0x1900>
ffffffffc0203bc4:	00002617          	auipc	a2,0x2
ffffffffc0203bc8:	dc460613          	addi	a2,a2,-572 # ffffffffc0205988 <commands+0x998>
ffffffffc0203bcc:	10700593          	li	a1,263
ffffffffc0203bd0:	00003517          	auipc	a0,0x3
ffffffffc0203bd4:	be050513          	addi	a0,a0,-1056 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203bd8:	dfefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p1 = alloc_pages(3)) != NULL);
ffffffffc0203bdc:	00003697          	auipc	a3,0x3
ffffffffc0203be0:	de468693          	addi	a3,a3,-540 # ffffffffc02069c0 <commands+0x19d0>
ffffffffc0203be4:	00002617          	auipc	a2,0x2
ffffffffc0203be8:	da460613          	addi	a2,a2,-604 # ffffffffc0205988 <commands+0x998>
ffffffffc0203bec:	10600593          	li	a1,262
ffffffffc0203bf0:	00003517          	auipc	a0,0x3
ffffffffc0203bf4:	bc050513          	addi	a0,a0,-1088 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203bf8:	ddefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(PageProperty(p0 + 2) && p0[2].property == 3);
ffffffffc0203bfc:	00003697          	auipc	a3,0x3
ffffffffc0203c00:	d9468693          	addi	a3,a3,-620 # ffffffffc0206990 <commands+0x19a0>
ffffffffc0203c04:	00002617          	auipc	a2,0x2
ffffffffc0203c08:	d8460613          	addi	a2,a2,-636 # ffffffffc0205988 <commands+0x998>
ffffffffc0203c0c:	10500593          	li	a1,261
ffffffffc0203c10:	00003517          	auipc	a0,0x3
ffffffffc0203c14:	ba050513          	addi	a0,a0,-1120 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203c18:	dbefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(alloc_pages(4) == NULL);
ffffffffc0203c1c:	00003697          	auipc	a3,0x3
ffffffffc0203c20:	d5c68693          	addi	a3,a3,-676 # ffffffffc0206978 <commands+0x1988>
ffffffffc0203c24:	00002617          	auipc	a2,0x2
ffffffffc0203c28:	d6460613          	addi	a2,a2,-668 # ffffffffc0205988 <commands+0x998>
ffffffffc0203c2c:	10400593          	li	a1,260
ffffffffc0203c30:	00003517          	auipc	a0,0x3
ffffffffc0203c34:	b8050513          	addi	a0,a0,-1152 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203c38:	d9efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(alloc_page() == NULL);
ffffffffc0203c3c:	00003697          	auipc	a3,0x3
ffffffffc0203c40:	cb468693          	addi	a3,a3,-844 # ffffffffc02068f0 <commands+0x1900>
ffffffffc0203c44:	00002617          	auipc	a2,0x2
ffffffffc0203c48:	d4460613          	addi	a2,a2,-700 # ffffffffc0205988 <commands+0x998>
ffffffffc0203c4c:	0fe00593          	li	a1,254
ffffffffc0203c50:	00003517          	auipc	a0,0x3
ffffffffc0203c54:	b6050513          	addi	a0,a0,-1184 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203c58:	d7efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(!PageProperty(p0));
ffffffffc0203c5c:	00003697          	auipc	a3,0x3
ffffffffc0203c60:	d0468693          	addi	a3,a3,-764 # ffffffffc0206960 <commands+0x1970>
ffffffffc0203c64:	00002617          	auipc	a2,0x2
ffffffffc0203c68:	d2460613          	addi	a2,a2,-732 # ffffffffc0205988 <commands+0x998>
ffffffffc0203c6c:	0f900593          	li	a1,249
ffffffffc0203c70:	00003517          	auipc	a0,0x3
ffffffffc0203c74:	b4050513          	addi	a0,a0,-1216 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203c78:	d5efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p0 = alloc_pages(5)) != NULL);
ffffffffc0203c7c:	00003697          	auipc	a3,0x3
ffffffffc0203c80:	e0468693          	addi	a3,a3,-508 # ffffffffc0206a80 <commands+0x1a90>
ffffffffc0203c84:	00002617          	auipc	a2,0x2
ffffffffc0203c88:	d0460613          	addi	a2,a2,-764 # ffffffffc0205988 <commands+0x998>
ffffffffc0203c8c:	11700593          	li	a1,279
ffffffffc0203c90:	00003517          	auipc	a0,0x3
ffffffffc0203c94:	b2050513          	addi	a0,a0,-1248 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203c98:	d3efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(total == 0);
ffffffffc0203c9c:	00003697          	auipc	a3,0x3
ffffffffc0203ca0:	e1468693          	addi	a3,a3,-492 # ffffffffc0206ab0 <commands+0x1ac0>
ffffffffc0203ca4:	00002617          	auipc	a2,0x2
ffffffffc0203ca8:	ce460613          	addi	a2,a2,-796 # ffffffffc0205988 <commands+0x998>
ffffffffc0203cac:	12600593          	li	a1,294
ffffffffc0203cb0:	00003517          	auipc	a0,0x3
ffffffffc0203cb4:	b0050513          	addi	a0,a0,-1280 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203cb8:	d1efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(total == nr_free_pages());
ffffffffc0203cbc:	00002697          	auipc	a3,0x2
ffffffffc0203cc0:	5b468693          	addi	a3,a3,1460 # ffffffffc0206270 <commands+0x1280>
ffffffffc0203cc4:	00002617          	auipc	a2,0x2
ffffffffc0203cc8:	cc460613          	addi	a2,a2,-828 # ffffffffc0205988 <commands+0x998>
ffffffffc0203ccc:	0f300593          	li	a1,243
ffffffffc0203cd0:	00003517          	auipc	a0,0x3
ffffffffc0203cd4:	ae050513          	addi	a0,a0,-1312 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203cd8:	cfefc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert((p1 = alloc_page()) != NULL);
ffffffffc0203cdc:	00003697          	auipc	a3,0x3
ffffffffc0203ce0:	b0c68693          	addi	a3,a3,-1268 # ffffffffc02067e8 <commands+0x17f8>
ffffffffc0203ce4:	00002617          	auipc	a2,0x2
ffffffffc0203ce8:	ca460613          	addi	a2,a2,-860 # ffffffffc0205988 <commands+0x998>
ffffffffc0203cec:	0ba00593          	li	a1,186
ffffffffc0203cf0:	00003517          	auipc	a0,0x3
ffffffffc0203cf4:	ac050513          	addi	a0,a0,-1344 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203cf8:	cdefc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0203cfc <default_free_pages>:
default_free_pages(struct Page *base, size_t n) {
ffffffffc0203cfc:	1141                	addi	sp,sp,-16
ffffffffc0203cfe:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc0203d00:	16058e63          	beqz	a1,ffffffffc0203e7c <default_free_pages+0x180>
    for (; p != base + n; p ++) {
ffffffffc0203d04:	00659693          	slli	a3,a1,0x6
ffffffffc0203d08:	96aa                	add	a3,a3,a0
ffffffffc0203d0a:	02d50d63          	beq	a0,a3,ffffffffc0203d44 <default_free_pages+0x48>
ffffffffc0203d0e:	651c                	ld	a5,8(a0)
        assert(!PageReserved(p) && !PageProperty(p));
ffffffffc0203d10:	8b85                	andi	a5,a5,1
ffffffffc0203d12:	14079563          	bnez	a5,ffffffffc0203e5c <default_free_pages+0x160>
ffffffffc0203d16:	651c                	ld	a5,8(a0)
ffffffffc0203d18:	8385                	srli	a5,a5,0x1
ffffffffc0203d1a:	8b85                	andi	a5,a5,1
ffffffffc0203d1c:	14079063          	bnez	a5,ffffffffc0203e5c <default_free_pages+0x160>
ffffffffc0203d20:	87aa                	mv	a5,a0
ffffffffc0203d22:	a809                	j	ffffffffc0203d34 <default_free_pages+0x38>
ffffffffc0203d24:	6798                	ld	a4,8(a5)
ffffffffc0203d26:	8b05                	andi	a4,a4,1
ffffffffc0203d28:	12071a63          	bnez	a4,ffffffffc0203e5c <default_free_pages+0x160>
ffffffffc0203d2c:	6798                	ld	a4,8(a5)
ffffffffc0203d2e:	8b09                	andi	a4,a4,2
ffffffffc0203d30:	12071663          	bnez	a4,ffffffffc0203e5c <default_free_pages+0x160>
        p->flags = 0;
ffffffffc0203d34:	0007b423          	sd	zero,8(a5)
    page->ref = val;
ffffffffc0203d38:	0007a023          	sw	zero,0(a5)
    for (; p != base + n; p ++) {
ffffffffc0203d3c:	04078793          	addi	a5,a5,64
ffffffffc0203d40:	fed792e3          	bne	a5,a3,ffffffffc0203d24 <default_free_pages+0x28>
    base->property = n;
ffffffffc0203d44:	2581                	sext.w	a1,a1
ffffffffc0203d46:	c90c                	sw	a1,16(a0)
    SetPageProperty(base);
ffffffffc0203d48:	00850893          	addi	a7,a0,8
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc0203d4c:	4789                	li	a5,2
ffffffffc0203d4e:	40f8b02f          	amoor.d	zero,a5,(a7)
    nr_free += n;
ffffffffc0203d52:	00012697          	auipc	a3,0x12
ffffffffc0203d56:	88668693          	addi	a3,a3,-1914 # ffffffffc02155d8 <free_area>
ffffffffc0203d5a:	4a98                	lw	a4,16(a3)
    return list->next == list;
ffffffffc0203d5c:	669c                	ld	a5,8(a3)
ffffffffc0203d5e:	9db9                	addw	a1,a1,a4
ffffffffc0203d60:	00012717          	auipc	a4,0x12
ffffffffc0203d64:	88b72423          	sw	a1,-1912(a4) # ffffffffc02155e8 <free_area+0x10>
    if (list_empty(&free_list)) {
ffffffffc0203d68:	0cd78163          	beq	a5,a3,ffffffffc0203e2a <default_free_pages+0x12e>
            struct Page* page = le2page(le, page_link);
ffffffffc0203d6c:	fe878713          	addi	a4,a5,-24
ffffffffc0203d70:	628c                	ld	a1,0(a3)
    if (list_empty(&free_list)) {
ffffffffc0203d72:	4801                	li	a6,0
ffffffffc0203d74:	01850613          	addi	a2,a0,24
            if (base < page) {
ffffffffc0203d78:	00e56a63          	bltu	a0,a4,ffffffffc0203d8c <default_free_pages+0x90>
    return listelm->next;
ffffffffc0203d7c:	6798                	ld	a4,8(a5)
            } else if (list_next(le) == &free_list) {
ffffffffc0203d7e:	04d70f63          	beq	a4,a3,ffffffffc0203ddc <default_free_pages+0xe0>
        while ((le = list_next(le)) != &free_list) {
ffffffffc0203d82:	87ba                	mv	a5,a4
            struct Page* page = le2page(le, page_link);
ffffffffc0203d84:	fe878713          	addi	a4,a5,-24
            if (base < page) {
ffffffffc0203d88:	fee57ae3          	bleu	a4,a0,ffffffffc0203d7c <default_free_pages+0x80>
ffffffffc0203d8c:	00080663          	beqz	a6,ffffffffc0203d98 <default_free_pages+0x9c>
ffffffffc0203d90:	00012817          	auipc	a6,0x12
ffffffffc0203d94:	84b83423          	sd	a1,-1976(a6) # ffffffffc02155d8 <free_area>
    __list_add(elm, listelm->prev, listelm);
ffffffffc0203d98:	638c                	ld	a1,0(a5)
    prev->next = next->prev = elm;
ffffffffc0203d9a:	e390                	sd	a2,0(a5)
ffffffffc0203d9c:	e590                	sd	a2,8(a1)
    elm->next = next;
ffffffffc0203d9e:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc0203da0:	ed0c                	sd	a1,24(a0)
    if (le != &free_list) {
ffffffffc0203da2:	06d58a63          	beq	a1,a3,ffffffffc0203e16 <default_free_pages+0x11a>
        if (p + p->property == base) {
ffffffffc0203da6:	ff85a603          	lw	a2,-8(a1) # ff8 <BASE_ADDRESS-0xffffffffc01ff008>
        p = le2page(le, page_link);
ffffffffc0203daa:	fe858713          	addi	a4,a1,-24
        if (p + p->property == base) {
ffffffffc0203dae:	02061793          	slli	a5,a2,0x20
ffffffffc0203db2:	83e9                	srli	a5,a5,0x1a
ffffffffc0203db4:	97ba                	add	a5,a5,a4
ffffffffc0203db6:	04f51b63          	bne	a0,a5,ffffffffc0203e0c <default_free_pages+0x110>
            p->property += base->property;
ffffffffc0203dba:	491c                	lw	a5,16(a0)
ffffffffc0203dbc:	9e3d                	addw	a2,a2,a5
ffffffffc0203dbe:	fec5ac23          	sw	a2,-8(a1)
    __op_bit(and, __NOT, nr, ((volatile unsigned long *)addr));
ffffffffc0203dc2:	57f5                	li	a5,-3
ffffffffc0203dc4:	60f8b02f          	amoand.d	zero,a5,(a7)
    __list_del(listelm->prev, listelm->next);
ffffffffc0203dc8:	01853803          	ld	a6,24(a0)
ffffffffc0203dcc:	7110                	ld	a2,32(a0)
            base = p;
ffffffffc0203dce:	853a                	mv	a0,a4
    prev->next = next;
ffffffffc0203dd0:	00c83423          	sd	a2,8(a6)
    next->prev = prev;
ffffffffc0203dd4:	659c                	ld	a5,8(a1)
ffffffffc0203dd6:	01063023          	sd	a6,0(a2)
ffffffffc0203dda:	a815                	j	ffffffffc0203e0e <default_free_pages+0x112>
    prev->next = next->prev = elm;
ffffffffc0203ddc:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc0203dde:	f114                	sd	a3,32(a0)
ffffffffc0203de0:	6798                	ld	a4,8(a5)
    elm->prev = prev;
ffffffffc0203de2:	ed1c                	sd	a5,24(a0)
                list_add(le, &(base->page_link));
ffffffffc0203de4:	85b2                	mv	a1,a2
        while ((le = list_next(le)) != &free_list) {
ffffffffc0203de6:	00d70563          	beq	a4,a3,ffffffffc0203df0 <default_free_pages+0xf4>
ffffffffc0203dea:	4805                	li	a6,1
ffffffffc0203dec:	87ba                	mv	a5,a4
ffffffffc0203dee:	bf59                	j	ffffffffc0203d84 <default_free_pages+0x88>
ffffffffc0203df0:	e290                	sd	a2,0(a3)
    return listelm->prev;
ffffffffc0203df2:	85be                	mv	a1,a5
    if (le != &free_list) {
ffffffffc0203df4:	00d78d63          	beq	a5,a3,ffffffffc0203e0e <default_free_pages+0x112>
        if (p + p->property == base) {
ffffffffc0203df8:	ff85a603          	lw	a2,-8(a1)
        p = le2page(le, page_link);
ffffffffc0203dfc:	fe858713          	addi	a4,a1,-24
        if (p + p->property == base) {
ffffffffc0203e00:	02061793          	slli	a5,a2,0x20
ffffffffc0203e04:	83e9                	srli	a5,a5,0x1a
ffffffffc0203e06:	97ba                	add	a5,a5,a4
ffffffffc0203e08:	faf509e3          	beq	a0,a5,ffffffffc0203dba <default_free_pages+0xbe>
ffffffffc0203e0c:	711c                	ld	a5,32(a0)
    if (le != &free_list) {
ffffffffc0203e0e:	fe878713          	addi	a4,a5,-24
ffffffffc0203e12:	00d78963          	beq	a5,a3,ffffffffc0203e24 <default_free_pages+0x128>
        if (base + base->property == p) {
ffffffffc0203e16:	4910                	lw	a2,16(a0)
ffffffffc0203e18:	02061693          	slli	a3,a2,0x20
ffffffffc0203e1c:	82e9                	srli	a3,a3,0x1a
ffffffffc0203e1e:	96aa                	add	a3,a3,a0
ffffffffc0203e20:	00d70e63          	beq	a4,a3,ffffffffc0203e3c <default_free_pages+0x140>
}
ffffffffc0203e24:	60a2                	ld	ra,8(sp)
ffffffffc0203e26:	0141                	addi	sp,sp,16
ffffffffc0203e28:	8082                	ret
ffffffffc0203e2a:	60a2                	ld	ra,8(sp)
        list_add(&free_list, &(base->page_link));
ffffffffc0203e2c:	01850713          	addi	a4,a0,24
    prev->next = next->prev = elm;
ffffffffc0203e30:	e398                	sd	a4,0(a5)
ffffffffc0203e32:	e798                	sd	a4,8(a5)
    elm->next = next;
ffffffffc0203e34:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc0203e36:	ed1c                	sd	a5,24(a0)
}
ffffffffc0203e38:	0141                	addi	sp,sp,16
ffffffffc0203e3a:	8082                	ret
            base->property += p->property;
ffffffffc0203e3c:	ff87a703          	lw	a4,-8(a5)
ffffffffc0203e40:	ff078693          	addi	a3,a5,-16
ffffffffc0203e44:	9e39                	addw	a2,a2,a4
ffffffffc0203e46:	c910                	sw	a2,16(a0)
ffffffffc0203e48:	5775                	li	a4,-3
ffffffffc0203e4a:	60e6b02f          	amoand.d	zero,a4,(a3)
    __list_del(listelm->prev, listelm->next);
ffffffffc0203e4e:	6398                	ld	a4,0(a5)
ffffffffc0203e50:	679c                	ld	a5,8(a5)
}
ffffffffc0203e52:	60a2                	ld	ra,8(sp)
    prev->next = next;
ffffffffc0203e54:	e71c                	sd	a5,8(a4)
    next->prev = prev;
ffffffffc0203e56:	e398                	sd	a4,0(a5)
ffffffffc0203e58:	0141                	addi	sp,sp,16
ffffffffc0203e5a:	8082                	ret
        assert(!PageReserved(p) && !PageProperty(p));
ffffffffc0203e5c:	00003697          	auipc	a3,0x3
ffffffffc0203e60:	c6468693          	addi	a3,a3,-924 # ffffffffc0206ac0 <commands+0x1ad0>
ffffffffc0203e64:	00002617          	auipc	a2,0x2
ffffffffc0203e68:	b2460613          	addi	a2,a2,-1244 # ffffffffc0205988 <commands+0x998>
ffffffffc0203e6c:	08300593          	li	a1,131
ffffffffc0203e70:	00003517          	auipc	a0,0x3
ffffffffc0203e74:	94050513          	addi	a0,a0,-1728 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203e78:	b5efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(n > 0);
ffffffffc0203e7c:	00003697          	auipc	a3,0x3
ffffffffc0203e80:	c6c68693          	addi	a3,a3,-916 # ffffffffc0206ae8 <commands+0x1af8>
ffffffffc0203e84:	00002617          	auipc	a2,0x2
ffffffffc0203e88:	b0460613          	addi	a2,a2,-1276 # ffffffffc0205988 <commands+0x998>
ffffffffc0203e8c:	08000593          	li	a1,128
ffffffffc0203e90:	00003517          	auipc	a0,0x3
ffffffffc0203e94:	92050513          	addi	a0,a0,-1760 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0203e98:	b3efc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0203e9c <default_alloc_pages>:
    assert(n > 0);
ffffffffc0203e9c:	c959                	beqz	a0,ffffffffc0203f32 <default_alloc_pages+0x96>
    if (n > nr_free) {
ffffffffc0203e9e:	00011597          	auipc	a1,0x11
ffffffffc0203ea2:	73a58593          	addi	a1,a1,1850 # ffffffffc02155d8 <free_area>
ffffffffc0203ea6:	0105a803          	lw	a6,16(a1)
ffffffffc0203eaa:	862a                	mv	a2,a0
ffffffffc0203eac:	02081793          	slli	a5,a6,0x20
ffffffffc0203eb0:	9381                	srli	a5,a5,0x20
ffffffffc0203eb2:	00a7ee63          	bltu	a5,a0,ffffffffc0203ece <default_alloc_pages+0x32>
    list_entry_t *le = &free_list;
ffffffffc0203eb6:	87ae                	mv	a5,a1
ffffffffc0203eb8:	a801                	j	ffffffffc0203ec8 <default_alloc_pages+0x2c>
        if (p->property >= n) {
ffffffffc0203eba:	ff87a703          	lw	a4,-8(a5)
ffffffffc0203ebe:	02071693          	slli	a3,a4,0x20
ffffffffc0203ec2:	9281                	srli	a3,a3,0x20
ffffffffc0203ec4:	00c6f763          	bleu	a2,a3,ffffffffc0203ed2 <default_alloc_pages+0x36>
    return listelm->next;
ffffffffc0203ec8:	679c                	ld	a5,8(a5)
    while ((le = list_next(le)) != &free_list) {
ffffffffc0203eca:	feb798e3          	bne	a5,a1,ffffffffc0203eba <default_alloc_pages+0x1e>
        return NULL;
ffffffffc0203ece:	4501                	li	a0,0
}
ffffffffc0203ed0:	8082                	ret
        struct Page *p = le2page(le, page_link);
ffffffffc0203ed2:	fe878513          	addi	a0,a5,-24
    if (page != NULL) {
ffffffffc0203ed6:	dd6d                	beqz	a0,ffffffffc0203ed0 <default_alloc_pages+0x34>
    return listelm->prev;
ffffffffc0203ed8:	0007b883          	ld	a7,0(a5)
    __list_del(listelm->prev, listelm->next);
ffffffffc0203edc:	0087b303          	ld	t1,8(a5)
    prev->next = next;
ffffffffc0203ee0:	00060e1b          	sext.w	t3,a2
ffffffffc0203ee4:	0068b423          	sd	t1,8(a7)
    next->prev = prev;
ffffffffc0203ee8:	01133023          	sd	a7,0(t1)
        if (page->property > n) {
ffffffffc0203eec:	02d67863          	bleu	a3,a2,ffffffffc0203f1c <default_alloc_pages+0x80>
            struct Page *p = page + n;
ffffffffc0203ef0:	061a                	slli	a2,a2,0x6
ffffffffc0203ef2:	962a                	add	a2,a2,a0
            p->property = page->property - n;
ffffffffc0203ef4:	41c7073b          	subw	a4,a4,t3
ffffffffc0203ef8:	ca18                	sw	a4,16(a2)
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc0203efa:	00860693          	addi	a3,a2,8
ffffffffc0203efe:	4709                	li	a4,2
ffffffffc0203f00:	40e6b02f          	amoor.d	zero,a4,(a3)
    __list_add(elm, listelm, listelm->next);
ffffffffc0203f04:	0088b703          	ld	a4,8(a7)
            list_add(prev, &(p->page_link));
ffffffffc0203f08:	01860693          	addi	a3,a2,24
    prev->next = next->prev = elm;
ffffffffc0203f0c:	0105a803          	lw	a6,16(a1)
ffffffffc0203f10:	e314                	sd	a3,0(a4)
ffffffffc0203f12:	00d8b423          	sd	a3,8(a7)
    elm->next = next;
ffffffffc0203f16:	f218                	sd	a4,32(a2)
    elm->prev = prev;
ffffffffc0203f18:	01163c23          	sd	a7,24(a2)
        nr_free -= n;
ffffffffc0203f1c:	41c8083b          	subw	a6,a6,t3
ffffffffc0203f20:	00011717          	auipc	a4,0x11
ffffffffc0203f24:	6d072423          	sw	a6,1736(a4) # ffffffffc02155e8 <free_area+0x10>
    __op_bit(and, __NOT, nr, ((volatile unsigned long *)addr));
ffffffffc0203f28:	5775                	li	a4,-3
ffffffffc0203f2a:	17c1                	addi	a5,a5,-16
ffffffffc0203f2c:	60e7b02f          	amoand.d	zero,a4,(a5)
ffffffffc0203f30:	8082                	ret
default_alloc_pages(size_t n) {
ffffffffc0203f32:	1141                	addi	sp,sp,-16
    assert(n > 0);
ffffffffc0203f34:	00003697          	auipc	a3,0x3
ffffffffc0203f38:	bb468693          	addi	a3,a3,-1100 # ffffffffc0206ae8 <commands+0x1af8>
ffffffffc0203f3c:	00002617          	auipc	a2,0x2
ffffffffc0203f40:	a4c60613          	addi	a2,a2,-1460 # ffffffffc0205988 <commands+0x998>
ffffffffc0203f44:	06200593          	li	a1,98
ffffffffc0203f48:	00003517          	auipc	a0,0x3
ffffffffc0203f4c:	86850513          	addi	a0,a0,-1944 # ffffffffc02067b0 <commands+0x17c0>
default_alloc_pages(size_t n) {
ffffffffc0203f50:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc0203f52:	a84fc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0203f56 <default_init_memmap>:
default_init_memmap(struct Page *base, size_t n) {
ffffffffc0203f56:	1141                	addi	sp,sp,-16
ffffffffc0203f58:	e406                	sd	ra,8(sp)
    assert(n > 0);
ffffffffc0203f5a:	c1ed                	beqz	a1,ffffffffc020403c <default_init_memmap+0xe6>
    for (; p != base + n; p ++) {
ffffffffc0203f5c:	00659693          	slli	a3,a1,0x6
ffffffffc0203f60:	96aa                	add	a3,a3,a0
ffffffffc0203f62:	02d50463          	beq	a0,a3,ffffffffc0203f8a <default_init_memmap+0x34>
    return (((*(volatile unsigned long *)addr) >> nr) & 1);
ffffffffc0203f66:	6518                	ld	a4,8(a0)
        assert(PageReserved(p));
ffffffffc0203f68:	87aa                	mv	a5,a0
ffffffffc0203f6a:	8b05                	andi	a4,a4,1
ffffffffc0203f6c:	e709                	bnez	a4,ffffffffc0203f76 <default_init_memmap+0x20>
ffffffffc0203f6e:	a07d                	j	ffffffffc020401c <default_init_memmap+0xc6>
ffffffffc0203f70:	6798                	ld	a4,8(a5)
ffffffffc0203f72:	8b05                	andi	a4,a4,1
ffffffffc0203f74:	c745                	beqz	a4,ffffffffc020401c <default_init_memmap+0xc6>
        p->flags = p->property = 0;
ffffffffc0203f76:	0007a823          	sw	zero,16(a5)
ffffffffc0203f7a:	0007b423          	sd	zero,8(a5)
ffffffffc0203f7e:	0007a023          	sw	zero,0(a5)
    for (; p != base + n; p ++) {
ffffffffc0203f82:	04078793          	addi	a5,a5,64
ffffffffc0203f86:	fed795e3          	bne	a5,a3,ffffffffc0203f70 <default_init_memmap+0x1a>
    base->property = n;
ffffffffc0203f8a:	2581                	sext.w	a1,a1
ffffffffc0203f8c:	c90c                	sw	a1,16(a0)
    __op_bit(or, __NOP, nr, ((volatile unsigned long *)addr));
ffffffffc0203f8e:	4789                	li	a5,2
ffffffffc0203f90:	00850713          	addi	a4,a0,8
ffffffffc0203f94:	40f7302f          	amoor.d	zero,a5,(a4)
    nr_free += n;
ffffffffc0203f98:	00011697          	auipc	a3,0x11
ffffffffc0203f9c:	64068693          	addi	a3,a3,1600 # ffffffffc02155d8 <free_area>
ffffffffc0203fa0:	4a98                	lw	a4,16(a3)
    return list->next == list;
ffffffffc0203fa2:	669c                	ld	a5,8(a3)
ffffffffc0203fa4:	9db9                	addw	a1,a1,a4
ffffffffc0203fa6:	00011717          	auipc	a4,0x11
ffffffffc0203faa:	64b72123          	sw	a1,1602(a4) # ffffffffc02155e8 <free_area+0x10>
    if (list_empty(&free_list)) {
ffffffffc0203fae:	04d78a63          	beq	a5,a3,ffffffffc0204002 <default_init_memmap+0xac>
            struct Page* page = le2page(le, page_link);
ffffffffc0203fb2:	fe878713          	addi	a4,a5,-24
ffffffffc0203fb6:	628c                	ld	a1,0(a3)
    if (list_empty(&free_list)) {
ffffffffc0203fb8:	4801                	li	a6,0
ffffffffc0203fba:	01850613          	addi	a2,a0,24
            if (base < page) {
ffffffffc0203fbe:	00e56a63          	bltu	a0,a4,ffffffffc0203fd2 <default_init_memmap+0x7c>
    return listelm->next;
ffffffffc0203fc2:	6798                	ld	a4,8(a5)
            } else if (list_next(le) == &free_list) {
ffffffffc0203fc4:	02d70563          	beq	a4,a3,ffffffffc0203fee <default_init_memmap+0x98>
        while ((le = list_next(le)) != &free_list) {
ffffffffc0203fc8:	87ba                	mv	a5,a4
            struct Page* page = le2page(le, page_link);
ffffffffc0203fca:	fe878713          	addi	a4,a5,-24
            if (base < page) {
ffffffffc0203fce:	fee57ae3          	bleu	a4,a0,ffffffffc0203fc2 <default_init_memmap+0x6c>
ffffffffc0203fd2:	00080663          	beqz	a6,ffffffffc0203fde <default_init_memmap+0x88>
ffffffffc0203fd6:	00011717          	auipc	a4,0x11
ffffffffc0203fda:	60b73123          	sd	a1,1538(a4) # ffffffffc02155d8 <free_area>
    __list_add(elm, listelm->prev, listelm);
ffffffffc0203fde:	6398                	ld	a4,0(a5)
}
ffffffffc0203fe0:	60a2                	ld	ra,8(sp)
    prev->next = next->prev = elm;
ffffffffc0203fe2:	e390                	sd	a2,0(a5)
ffffffffc0203fe4:	e710                	sd	a2,8(a4)
    elm->next = next;
ffffffffc0203fe6:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc0203fe8:	ed18                	sd	a4,24(a0)
ffffffffc0203fea:	0141                	addi	sp,sp,16
ffffffffc0203fec:	8082                	ret
    prev->next = next->prev = elm;
ffffffffc0203fee:	e790                	sd	a2,8(a5)
    elm->next = next;
ffffffffc0203ff0:	f114                	sd	a3,32(a0)
ffffffffc0203ff2:	6798                	ld	a4,8(a5)
    elm->prev = prev;
ffffffffc0203ff4:	ed1c                	sd	a5,24(a0)
                list_add(le, &(base->page_link));
ffffffffc0203ff6:	85b2                	mv	a1,a2
        while ((le = list_next(le)) != &free_list) {
ffffffffc0203ff8:	00d70e63          	beq	a4,a3,ffffffffc0204014 <default_init_memmap+0xbe>
ffffffffc0203ffc:	4805                	li	a6,1
ffffffffc0203ffe:	87ba                	mv	a5,a4
ffffffffc0204000:	b7e9                	j	ffffffffc0203fca <default_init_memmap+0x74>
}
ffffffffc0204002:	60a2                	ld	ra,8(sp)
        list_add(&free_list, &(base->page_link));
ffffffffc0204004:	01850713          	addi	a4,a0,24
    prev->next = next->prev = elm;
ffffffffc0204008:	e398                	sd	a4,0(a5)
ffffffffc020400a:	e798                	sd	a4,8(a5)
    elm->next = next;
ffffffffc020400c:	f11c                	sd	a5,32(a0)
    elm->prev = prev;
ffffffffc020400e:	ed1c                	sd	a5,24(a0)
}
ffffffffc0204010:	0141                	addi	sp,sp,16
ffffffffc0204012:	8082                	ret
ffffffffc0204014:	60a2                	ld	ra,8(sp)
ffffffffc0204016:	e290                	sd	a2,0(a3)
ffffffffc0204018:	0141                	addi	sp,sp,16
ffffffffc020401a:	8082                	ret
        assert(PageReserved(p));
ffffffffc020401c:	00003697          	auipc	a3,0x3
ffffffffc0204020:	ad468693          	addi	a3,a3,-1324 # ffffffffc0206af0 <commands+0x1b00>
ffffffffc0204024:	00002617          	auipc	a2,0x2
ffffffffc0204028:	96460613          	addi	a2,a2,-1692 # ffffffffc0205988 <commands+0x998>
ffffffffc020402c:	04900593          	li	a1,73
ffffffffc0204030:	00002517          	auipc	a0,0x2
ffffffffc0204034:	78050513          	addi	a0,a0,1920 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0204038:	99efc0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(n > 0);
ffffffffc020403c:	00003697          	auipc	a3,0x3
ffffffffc0204040:	aac68693          	addi	a3,a3,-1364 # ffffffffc0206ae8 <commands+0x1af8>
ffffffffc0204044:	00002617          	auipc	a2,0x2
ffffffffc0204048:	94460613          	addi	a2,a2,-1724 # ffffffffc0205988 <commands+0x998>
ffffffffc020404c:	04600593          	li	a1,70
ffffffffc0204050:	00002517          	auipc	a0,0x2
ffffffffc0204054:	76050513          	addi	a0,a0,1888 # ffffffffc02067b0 <commands+0x17c0>
ffffffffc0204058:	97efc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc020405c <swapfs_init>:
#include <ide.h>
#include <pmm.h>
#include <assert.h>

void
swapfs_init(void) {
ffffffffc020405c:	1141                	addi	sp,sp,-16
    static_assert((PGSIZE % SECTSIZE) == 0);
    if (!ide_device_valid(SWAP_DEV_NO)) {
ffffffffc020405e:	4505                	li	a0,1
swapfs_init(void) {
ffffffffc0204060:	e406                	sd	ra,8(sp)
    if (!ide_device_valid(SWAP_DEV_NO)) {
ffffffffc0204062:	c50fc0ef          	jal	ra,ffffffffc02004b2 <ide_device_valid>
ffffffffc0204066:	cd01                	beqz	a0,ffffffffc020407e <swapfs_init+0x22>
        panic("swap fs isn't available.\n");
    }
    max_swap_offset = ide_device_size(SWAP_DEV_NO) / (PGSIZE / SECTSIZE);
ffffffffc0204068:	4505                	li	a0,1
ffffffffc020406a:	c4efc0ef          	jal	ra,ffffffffc02004b8 <ide_device_size>
}
ffffffffc020406e:	60a2                	ld	ra,8(sp)
    max_swap_offset = ide_device_size(SWAP_DEV_NO) / (PGSIZE / SECTSIZE);
ffffffffc0204070:	810d                	srli	a0,a0,0x3
ffffffffc0204072:	00011797          	auipc	a5,0x11
ffffffffc0204076:	50a7bb23          	sd	a0,1302(a5) # ffffffffc0215588 <max_swap_offset>
}
ffffffffc020407a:	0141                	addi	sp,sp,16
ffffffffc020407c:	8082                	ret
        panic("swap fs isn't available.\n");
ffffffffc020407e:	00003617          	auipc	a2,0x3
ffffffffc0204082:	ad260613          	addi	a2,a2,-1326 # ffffffffc0206b50 <default_pmm_manager+0x50>
ffffffffc0204086:	45b5                	li	a1,13
ffffffffc0204088:	00003517          	auipc	a0,0x3
ffffffffc020408c:	ae850513          	addi	a0,a0,-1304 # ffffffffc0206b70 <default_pmm_manager+0x70>
ffffffffc0204090:	946fc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0204094 <swapfs_read>:

int
swapfs_read(swap_entry_t entry, struct Page *page) {
ffffffffc0204094:	1141                	addi	sp,sp,-16
ffffffffc0204096:	e406                	sd	ra,8(sp)
    return ide_read_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT);
ffffffffc0204098:	00855793          	srli	a5,a0,0x8
ffffffffc020409c:	cfb9                	beqz	a5,ffffffffc02040fa <swapfs_read+0x66>
ffffffffc020409e:	00011717          	auipc	a4,0x11
ffffffffc02040a2:	4ea70713          	addi	a4,a4,1258 # ffffffffc0215588 <max_swap_offset>
ffffffffc02040a6:	6318                	ld	a4,0(a4)
ffffffffc02040a8:	04e7f963          	bleu	a4,a5,ffffffffc02040fa <swapfs_read+0x66>
    return page - pages + nbase;
ffffffffc02040ac:	00011717          	auipc	a4,0x11
ffffffffc02040b0:	44470713          	addi	a4,a4,1092 # ffffffffc02154f0 <pages>
ffffffffc02040b4:	6310                	ld	a2,0(a4)
ffffffffc02040b6:	00003717          	auipc	a4,0x3
ffffffffc02040ba:	eea70713          	addi	a4,a4,-278 # ffffffffc0206fa0 <nbase>
    return KADDR(page2pa(page));
ffffffffc02040be:	00011697          	auipc	a3,0x11
ffffffffc02040c2:	3ca68693          	addi	a3,a3,970 # ffffffffc0215488 <npage>
    return page - pages + nbase;
ffffffffc02040c6:	40c58633          	sub	a2,a1,a2
ffffffffc02040ca:	630c                	ld	a1,0(a4)
ffffffffc02040cc:	8619                	srai	a2,a2,0x6
    return KADDR(page2pa(page));
ffffffffc02040ce:	577d                	li	a4,-1
ffffffffc02040d0:	6294                	ld	a3,0(a3)
    return page - pages + nbase;
ffffffffc02040d2:	962e                	add	a2,a2,a1
    return KADDR(page2pa(page));
ffffffffc02040d4:	8331                	srli	a4,a4,0xc
ffffffffc02040d6:	8f71                	and	a4,a4,a2
ffffffffc02040d8:	0037959b          	slliw	a1,a5,0x3
    return page2ppn(page) << PGSHIFT;
ffffffffc02040dc:	0632                	slli	a2,a2,0xc
    return KADDR(page2pa(page));
ffffffffc02040de:	02d77a63          	bleu	a3,a4,ffffffffc0204112 <swapfs_read+0x7e>
ffffffffc02040e2:	00011797          	auipc	a5,0x11
ffffffffc02040e6:	3fe78793          	addi	a5,a5,1022 # ffffffffc02154e0 <va_pa_offset>
ffffffffc02040ea:	639c                	ld	a5,0(a5)
}
ffffffffc02040ec:	60a2                	ld	ra,8(sp)
    return ide_read_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT);
ffffffffc02040ee:	46a1                	li	a3,8
ffffffffc02040f0:	963e                	add	a2,a2,a5
ffffffffc02040f2:	4505                	li	a0,1
}
ffffffffc02040f4:	0141                	addi	sp,sp,16
    return ide_read_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT);
ffffffffc02040f6:	bc8fc06f          	j	ffffffffc02004be <ide_read_secs>
ffffffffc02040fa:	86aa                	mv	a3,a0
ffffffffc02040fc:	00003617          	auipc	a2,0x3
ffffffffc0204100:	a8c60613          	addi	a2,a2,-1396 # ffffffffc0206b88 <default_pmm_manager+0x88>
ffffffffc0204104:	45d1                	li	a1,20
ffffffffc0204106:	00003517          	auipc	a0,0x3
ffffffffc020410a:	a6a50513          	addi	a0,a0,-1430 # ffffffffc0206b70 <default_pmm_manager+0x70>
ffffffffc020410e:	8c8fc0ef          	jal	ra,ffffffffc02001d6 <__panic>
ffffffffc0204112:	86b2                	mv	a3,a2
ffffffffc0204114:	06900593          	li	a1,105
ffffffffc0204118:	00001617          	auipc	a2,0x1
ffffffffc020411c:	71860613          	addi	a2,a2,1816 # ffffffffc0205830 <commands+0x840>
ffffffffc0204120:	00001517          	auipc	a0,0x1
ffffffffc0204124:	76850513          	addi	a0,a0,1896 # ffffffffc0205888 <commands+0x898>
ffffffffc0204128:	8aefc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc020412c <swapfs_write>:

int
swapfs_write(swap_entry_t entry, struct Page *page) {
ffffffffc020412c:	1141                	addi	sp,sp,-16
ffffffffc020412e:	e406                	sd	ra,8(sp)
    return ide_write_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT);
ffffffffc0204130:	00855793          	srli	a5,a0,0x8
ffffffffc0204134:	cfb9                	beqz	a5,ffffffffc0204192 <swapfs_write+0x66>
ffffffffc0204136:	00011717          	auipc	a4,0x11
ffffffffc020413a:	45270713          	addi	a4,a4,1106 # ffffffffc0215588 <max_swap_offset>
ffffffffc020413e:	6318                	ld	a4,0(a4)
ffffffffc0204140:	04e7f963          	bleu	a4,a5,ffffffffc0204192 <swapfs_write+0x66>
    return page - pages + nbase;
ffffffffc0204144:	00011717          	auipc	a4,0x11
ffffffffc0204148:	3ac70713          	addi	a4,a4,940 # ffffffffc02154f0 <pages>
ffffffffc020414c:	6310                	ld	a2,0(a4)
ffffffffc020414e:	00003717          	auipc	a4,0x3
ffffffffc0204152:	e5270713          	addi	a4,a4,-430 # ffffffffc0206fa0 <nbase>
    return KADDR(page2pa(page));
ffffffffc0204156:	00011697          	auipc	a3,0x11
ffffffffc020415a:	33268693          	addi	a3,a3,818 # ffffffffc0215488 <npage>
    return page - pages + nbase;
ffffffffc020415e:	40c58633          	sub	a2,a1,a2
ffffffffc0204162:	630c                	ld	a1,0(a4)
ffffffffc0204164:	8619                	srai	a2,a2,0x6
    return KADDR(page2pa(page));
ffffffffc0204166:	577d                	li	a4,-1
ffffffffc0204168:	6294                	ld	a3,0(a3)
    return page - pages + nbase;
ffffffffc020416a:	962e                	add	a2,a2,a1
    return KADDR(page2pa(page));
ffffffffc020416c:	8331                	srli	a4,a4,0xc
ffffffffc020416e:	8f71                	and	a4,a4,a2
ffffffffc0204170:	0037959b          	slliw	a1,a5,0x3
    return page2ppn(page) << PGSHIFT;
ffffffffc0204174:	0632                	slli	a2,a2,0xc
    return KADDR(page2pa(page));
ffffffffc0204176:	02d77a63          	bleu	a3,a4,ffffffffc02041aa <swapfs_write+0x7e>
ffffffffc020417a:	00011797          	auipc	a5,0x11
ffffffffc020417e:	36678793          	addi	a5,a5,870 # ffffffffc02154e0 <va_pa_offset>
ffffffffc0204182:	639c                	ld	a5,0(a5)
}
ffffffffc0204184:	60a2                	ld	ra,8(sp)
    return ide_write_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT);
ffffffffc0204186:	46a1                	li	a3,8
ffffffffc0204188:	963e                	add	a2,a2,a5
ffffffffc020418a:	4505                	li	a0,1
}
ffffffffc020418c:	0141                	addi	sp,sp,16
    return ide_write_secs(SWAP_DEV_NO, swap_offset(entry) * PAGE_NSECT, page2kva(page), PAGE_NSECT);
ffffffffc020418e:	b54fc06f          	j	ffffffffc02004e2 <ide_write_secs>
ffffffffc0204192:	86aa                	mv	a3,a0
ffffffffc0204194:	00003617          	auipc	a2,0x3
ffffffffc0204198:	9f460613          	addi	a2,a2,-1548 # ffffffffc0206b88 <default_pmm_manager+0x88>
ffffffffc020419c:	45e5                	li	a1,25
ffffffffc020419e:	00003517          	auipc	a0,0x3
ffffffffc02041a2:	9d250513          	addi	a0,a0,-1582 # ffffffffc0206b70 <default_pmm_manager+0x70>
ffffffffc02041a6:	830fc0ef          	jal	ra,ffffffffc02001d6 <__panic>
ffffffffc02041aa:	86b2                	mv	a3,a2
ffffffffc02041ac:	06900593          	li	a1,105
ffffffffc02041b0:	00001617          	auipc	a2,0x1
ffffffffc02041b4:	68060613          	addi	a2,a2,1664 # ffffffffc0205830 <commands+0x840>
ffffffffc02041b8:	00001517          	auipc	a0,0x1
ffffffffc02041bc:	6d050513          	addi	a0,a0,1744 # ffffffffc0205888 <commands+0x898>
ffffffffc02041c0:	816fc0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc02041c4 <switch_to>:
.text
# void switch_to(struct proc_struct* from, struct proc_struct* to)
.globl switch_to
switch_to:
    # save from's registers
    STORE ra, 0*REGBYTES(a0)
ffffffffc02041c4:	00153023          	sd	ra,0(a0)
    STORE sp, 1*REGBYTES(a0)
ffffffffc02041c8:	00253423          	sd	sp,8(a0)
    STORE s0, 2*REGBYTES(a0)
ffffffffc02041cc:	e900                	sd	s0,16(a0)
    STORE s1, 3*REGBYTES(a0)
ffffffffc02041ce:	ed04                	sd	s1,24(a0)
    STORE s2, 4*REGBYTES(a0)
ffffffffc02041d0:	03253023          	sd	s2,32(a0)
    STORE s3, 5*REGBYTES(a0)
ffffffffc02041d4:	03353423          	sd	s3,40(a0)
    STORE s4, 6*REGBYTES(a0)
ffffffffc02041d8:	03453823          	sd	s4,48(a0)
    STORE s5, 7*REGBYTES(a0)
ffffffffc02041dc:	03553c23          	sd	s5,56(a0)
    STORE s6, 8*REGBYTES(a0)
ffffffffc02041e0:	05653023          	sd	s6,64(a0)
    STORE s7, 9*REGBYTES(a0)
ffffffffc02041e4:	05753423          	sd	s7,72(a0)
    STORE s8, 10*REGBYTES(a0)
ffffffffc02041e8:	05853823          	sd	s8,80(a0)
    STORE s9, 11*REGBYTES(a0)
ffffffffc02041ec:	05953c23          	sd	s9,88(a0)
    STORE s10, 12*REGBYTES(a0)
ffffffffc02041f0:	07a53023          	sd	s10,96(a0)
    STORE s11, 13*REGBYTES(a0)
ffffffffc02041f4:	07b53423          	sd	s11,104(a0)

    # restore to's registers
    LOAD ra, 0*REGBYTES(a1)
ffffffffc02041f8:	0005b083          	ld	ra,0(a1)
    LOAD sp, 1*REGBYTES(a1)
ffffffffc02041fc:	0085b103          	ld	sp,8(a1)
    LOAD s0, 2*REGBYTES(a1)
ffffffffc0204200:	6980                	ld	s0,16(a1)
    LOAD s1, 3*REGBYTES(a1)
ffffffffc0204202:	6d84                	ld	s1,24(a1)
    LOAD s2, 4*REGBYTES(a1)
ffffffffc0204204:	0205b903          	ld	s2,32(a1)
    LOAD s3, 5*REGBYTES(a1)
ffffffffc0204208:	0285b983          	ld	s3,40(a1)
    LOAD s4, 6*REGBYTES(a1)
ffffffffc020420c:	0305ba03          	ld	s4,48(a1)
    LOAD s5, 7*REGBYTES(a1)
ffffffffc0204210:	0385ba83          	ld	s5,56(a1)
    LOAD s6, 8*REGBYTES(a1)
ffffffffc0204214:	0405bb03          	ld	s6,64(a1)
    LOAD s7, 9*REGBYTES(a1)
ffffffffc0204218:	0485bb83          	ld	s7,72(a1)
    LOAD s8, 10*REGBYTES(a1)
ffffffffc020421c:	0505bc03          	ld	s8,80(a1)
    LOAD s9, 11*REGBYTES(a1)
ffffffffc0204220:	0585bc83          	ld	s9,88(a1)
    LOAD s10, 12*REGBYTES(a1)
ffffffffc0204224:	0605bd03          	ld	s10,96(a1)
    LOAD s11, 13*REGBYTES(a1)
ffffffffc0204228:	0685bd83          	ld	s11,104(a1)

    ret
ffffffffc020422c:	8082                	ret

ffffffffc020422e <kernel_thread_entry>:
.text
.globl kernel_thread_entry
kernel_thread_entry:        # void kernel_thread(void)
	move a0, s1
ffffffffc020422e:	8526                	mv	a0,s1
	jalr s0
ffffffffc0204230:	9402                	jalr	s0

	jal do_exit
ffffffffc0204232:	46e000ef          	jal	ra,ffffffffc02046a0 <do_exit>

ffffffffc0204236 <alloc_proc>:
void forkrets(struct trapframe *tf);
void switch_to(struct context *from, struct context *to);

// alloc_proc - alloc a proc_struct and init all fields of proc_struct
static struct proc_struct *
alloc_proc(void) {
ffffffffc0204236:	1141                	addi	sp,sp,-16
    struct proc_struct *proc = kmalloc(sizeof(struct proc_struct));
ffffffffc0204238:	0e800513          	li	a0,232
alloc_proc(void) {
ffffffffc020423c:	e022                	sd	s0,0(sp)
ffffffffc020423e:	e406                	sd	ra,8(sp)
    struct proc_struct *proc = kmalloc(sizeof(struct proc_struct));
ffffffffc0204240:	d07fe0ef          	jal	ra,ffffffffc0202f46 <kmalloc>
ffffffffc0204244:	842a                	mv	s0,a0
    if (proc != NULL) {
ffffffffc0204246:	c529                	beqz	a0,ffffffffc0204290 <alloc_proc+0x5a>
     *       uintptr_t cr3;                              // CR3 register: the base addr of Page Directroy Table(PDT)
     *       uint32_t flags;                             // Process flag
     *       char name[PROC_NAME_LEN + 1];               // Process name
     */

    proc->state = PROC_UNINIT;
ffffffffc0204248:	57fd                	li	a5,-1
ffffffffc020424a:	1782                	slli	a5,a5,0x20
ffffffffc020424c:	e11c                	sd	a5,0(a0)
    proc->tf = NULL;

    proc->flags = 0;


    proc->cr3 = boot_cr3;
ffffffffc020424e:	00011797          	auipc	a5,0x11
ffffffffc0204252:	29a78793          	addi	a5,a5,666 # ffffffffc02154e8 <boot_cr3>
ffffffffc0204256:	639c                	ld	a5,0(a5)

    memset(&(proc->context), 0, sizeof(struct context)); 
ffffffffc0204258:	07000613          	li	a2,112
ffffffffc020425c:	4581                	li	a1,0
    proc->kstack = 0;
ffffffffc020425e:	00053823          	sd	zero,16(a0)
    proc->runs = 0;
ffffffffc0204262:	00052423          	sw	zero,8(a0)
    proc->need_resched  = 0;
ffffffffc0204266:	00052c23          	sw	zero,24(a0)
    proc->parent = NULL;
ffffffffc020426a:	02053023          	sd	zero,32(a0)
    proc->mm = NULL;
ffffffffc020426e:	02053423          	sd	zero,40(a0)
    proc->tf = NULL;
ffffffffc0204272:	0a053023          	sd	zero,160(a0)
    proc->flags = 0;
ffffffffc0204276:	0a052823          	sw	zero,176(a0)
    proc->cr3 = boot_cr3;
ffffffffc020427a:	f55c                	sd	a5,168(a0)
    memset(&(proc->context), 0, sizeof(struct context)); 
ffffffffc020427c:	03050513          	addi	a0,a0,48
ffffffffc0204280:	7b6000ef          	jal	ra,ffffffffc0204a36 <memset>
    memset(proc->name, 0, PROC_NAME_LEN + 1);
ffffffffc0204284:	4641                	li	a2,16
ffffffffc0204286:	4581                	li	a1,0
ffffffffc0204288:	0b440513          	addi	a0,s0,180
ffffffffc020428c:	7aa000ef          	jal	ra,ffffffffc0204a36 <memset>


    }
    return proc;
}
ffffffffc0204290:	8522                	mv	a0,s0
ffffffffc0204292:	60a2                	ld	ra,8(sp)
ffffffffc0204294:	6402                	ld	s0,0(sp)
ffffffffc0204296:	0141                	addi	sp,sp,16
ffffffffc0204298:	8082                	ret

ffffffffc020429a <forkret>:
// forkret -- the first kernel entry point of a new thread/process
// NOTE: the addr of forkret is setted in copy_thread function
//       after switch_to, the current proc will execute here.
static void
forkret(void) {
    forkrets(current->tf);
ffffffffc020429a:	00011797          	auipc	a5,0x11
ffffffffc020429e:	21678793          	addi	a5,a5,534 # ffffffffc02154b0 <current>
ffffffffc02042a2:	639c                	ld	a5,0(a5)
ffffffffc02042a4:	73c8                	ld	a0,160(a5)
ffffffffc02042a6:	8f3fc06f          	j	ffffffffc0200b98 <forkrets>

ffffffffc02042aa <set_proc_name>:
set_proc_name(struct proc_struct *proc, const char *name) {
ffffffffc02042aa:	1101                	addi	sp,sp,-32
ffffffffc02042ac:	e822                	sd	s0,16(sp)
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc02042ae:	0b450413          	addi	s0,a0,180
set_proc_name(struct proc_struct *proc, const char *name) {
ffffffffc02042b2:	e426                	sd	s1,8(sp)
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc02042b4:	4641                	li	a2,16
set_proc_name(struct proc_struct *proc, const char *name) {
ffffffffc02042b6:	84ae                	mv	s1,a1
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc02042b8:	8522                	mv	a0,s0
ffffffffc02042ba:	4581                	li	a1,0
set_proc_name(struct proc_struct *proc, const char *name) {
ffffffffc02042bc:	ec06                	sd	ra,24(sp)
    memset(proc->name, 0, sizeof(proc->name));
ffffffffc02042be:	778000ef          	jal	ra,ffffffffc0204a36 <memset>
    return memcpy(proc->name, name, PROC_NAME_LEN);
ffffffffc02042c2:	8522                	mv	a0,s0
}
ffffffffc02042c4:	6442                	ld	s0,16(sp)
ffffffffc02042c6:	60e2                	ld	ra,24(sp)
    return memcpy(proc->name, name, PROC_NAME_LEN);
ffffffffc02042c8:	85a6                	mv	a1,s1
}
ffffffffc02042ca:	64a2                	ld	s1,8(sp)
    return memcpy(proc->name, name, PROC_NAME_LEN);
ffffffffc02042cc:	463d                	li	a2,15
}
ffffffffc02042ce:	6105                	addi	sp,sp,32
    return memcpy(proc->name, name, PROC_NAME_LEN);
ffffffffc02042d0:	7780006f          	j	ffffffffc0204a48 <memcpy>

ffffffffc02042d4 <get_proc_name>:
get_proc_name(struct proc_struct *proc) {
ffffffffc02042d4:	1101                	addi	sp,sp,-32
ffffffffc02042d6:	e822                	sd	s0,16(sp)
    memset(name, 0, sizeof(name));
ffffffffc02042d8:	00011417          	auipc	s0,0x11
ffffffffc02042dc:	18840413          	addi	s0,s0,392 # ffffffffc0215460 <name.1565>
get_proc_name(struct proc_struct *proc) {
ffffffffc02042e0:	e426                	sd	s1,8(sp)
    memset(name, 0, sizeof(name));
ffffffffc02042e2:	4641                	li	a2,16
get_proc_name(struct proc_struct *proc) {
ffffffffc02042e4:	84aa                	mv	s1,a0
    memset(name, 0, sizeof(name));
ffffffffc02042e6:	4581                	li	a1,0
ffffffffc02042e8:	8522                	mv	a0,s0
get_proc_name(struct proc_struct *proc) {
ffffffffc02042ea:	ec06                	sd	ra,24(sp)
    memset(name, 0, sizeof(name));
ffffffffc02042ec:	74a000ef          	jal	ra,ffffffffc0204a36 <memset>
    return memcpy(name, proc->name, PROC_NAME_LEN);
ffffffffc02042f0:	8522                	mv	a0,s0
}
ffffffffc02042f2:	6442                	ld	s0,16(sp)
ffffffffc02042f4:	60e2                	ld	ra,24(sp)
    return memcpy(name, proc->name, PROC_NAME_LEN);
ffffffffc02042f6:	0b448593          	addi	a1,s1,180
}
ffffffffc02042fa:	64a2                	ld	s1,8(sp)
    return memcpy(name, proc->name, PROC_NAME_LEN);
ffffffffc02042fc:	463d                	li	a2,15
}
ffffffffc02042fe:	6105                	addi	sp,sp,32
    return memcpy(name, proc->name, PROC_NAME_LEN);
ffffffffc0204300:	7480006f          	j	ffffffffc0204a48 <memcpy>

ffffffffc0204304 <init_main>:
}

// init_main - the second kernel thread used to create user_main kernel threads
static int
init_main(void *arg) {
    cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current));
ffffffffc0204304:	00011797          	auipc	a5,0x11
ffffffffc0204308:	1ac78793          	addi	a5,a5,428 # ffffffffc02154b0 <current>
ffffffffc020430c:	639c                	ld	a5,0(a5)
init_main(void *arg) {
ffffffffc020430e:	1101                	addi	sp,sp,-32
ffffffffc0204310:	e426                	sd	s1,8(sp)
    cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current));
ffffffffc0204312:	43c4                	lw	s1,4(a5)
init_main(void *arg) {
ffffffffc0204314:	e822                	sd	s0,16(sp)
ffffffffc0204316:	842a                	mv	s0,a0
    cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current));
ffffffffc0204318:	853e                	mv	a0,a5
init_main(void *arg) {
ffffffffc020431a:	ec06                	sd	ra,24(sp)
    cprintf("this initproc, pid = %d, name = \"%s\"\n", current->pid, get_proc_name(current));
ffffffffc020431c:	fb9ff0ef          	jal	ra,ffffffffc02042d4 <get_proc_name>
ffffffffc0204320:	862a                	mv	a2,a0
ffffffffc0204322:	85a6                	mv	a1,s1
ffffffffc0204324:	00003517          	auipc	a0,0x3
ffffffffc0204328:	8cc50513          	addi	a0,a0,-1844 # ffffffffc0206bf0 <default_pmm_manager+0xf0>
ffffffffc020432c:	da5fb0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("To U: \"%s\".\n", (const char *)arg);
ffffffffc0204330:	85a2                	mv	a1,s0
ffffffffc0204332:	00003517          	auipc	a0,0x3
ffffffffc0204336:	8e650513          	addi	a0,a0,-1818 # ffffffffc0206c18 <default_pmm_manager+0x118>
ffffffffc020433a:	d97fb0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    cprintf("To U: \"en.., Bye, Bye. :)\"\n");
ffffffffc020433e:	00003517          	auipc	a0,0x3
ffffffffc0204342:	8ea50513          	addi	a0,a0,-1814 # ffffffffc0206c28 <default_pmm_manager+0x128>
ffffffffc0204346:	d8bfb0ef          	jal	ra,ffffffffc02000d0 <cprintf>
    return 0;
}
ffffffffc020434a:	60e2                	ld	ra,24(sp)
ffffffffc020434c:	6442                	ld	s0,16(sp)
ffffffffc020434e:	64a2                	ld	s1,8(sp)
ffffffffc0204350:	4501                	li	a0,0
ffffffffc0204352:	6105                	addi	sp,sp,32
ffffffffc0204354:	8082                	ret

ffffffffc0204356 <proc_run>:
proc_run(struct proc_struct *proc) {
ffffffffc0204356:	1101                	addi	sp,sp,-32
    if (proc != current) {
ffffffffc0204358:	00011797          	auipc	a5,0x11
ffffffffc020435c:	15878793          	addi	a5,a5,344 # ffffffffc02154b0 <current>
proc_run(struct proc_struct *proc) {
ffffffffc0204360:	e426                	sd	s1,8(sp)
    if (proc != current) {
ffffffffc0204362:	6384                	ld	s1,0(a5)
proc_run(struct proc_struct *proc) {
ffffffffc0204364:	ec06                	sd	ra,24(sp)
ffffffffc0204366:	e822                	sd	s0,16(sp)
ffffffffc0204368:	e04a                	sd	s2,0(sp)
    if (proc != current) {
ffffffffc020436a:	02a48c63          	beq	s1,a0,ffffffffc02043a2 <proc_run+0x4c>
ffffffffc020436e:	842a                	mv	s0,a0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0204370:	100027f3          	csrr	a5,sstatus
ffffffffc0204374:	8b89                	andi	a5,a5,2
    return 0;
ffffffffc0204376:	4901                	li	s2,0
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0204378:	e3b1                	bnez	a5,ffffffffc02043bc <proc_run+0x66>
        lcr3(next->cr3);
ffffffffc020437a:	745c                	ld	a5,168(s0)
        current = proc;
ffffffffc020437c:	00011717          	auipc	a4,0x11
ffffffffc0204380:	12873a23          	sd	s0,308(a4) # ffffffffc02154b0 <current>

#define barrier() __asm__ __volatile__ ("fence" ::: "memory")

static inline void
lcr3(unsigned int cr3) {
    write_csr(sptbr, SATP32_MODE | (cr3 >> RISCV_PGSHIFT));
ffffffffc0204384:	80000737          	lui	a4,0x80000
ffffffffc0204388:	00c7d79b          	srliw	a5,a5,0xc
ffffffffc020438c:	8fd9                	or	a5,a5,a4
ffffffffc020438e:	18079073          	csrw	satp,a5
        switch_to(&(prev->context),&(next->context));
ffffffffc0204392:	03040593          	addi	a1,s0,48
ffffffffc0204396:	03048513          	addi	a0,s1,48
ffffffffc020439a:	e2bff0ef          	jal	ra,ffffffffc02041c4 <switch_to>
    if (flag) {
ffffffffc020439e:	00091863          	bnez	s2,ffffffffc02043ae <proc_run+0x58>
}
ffffffffc02043a2:	60e2                	ld	ra,24(sp)
ffffffffc02043a4:	6442                	ld	s0,16(sp)
ffffffffc02043a6:	64a2                	ld	s1,8(sp)
ffffffffc02043a8:	6902                	ld	s2,0(sp)
ffffffffc02043aa:	6105                	addi	sp,sp,32
ffffffffc02043ac:	8082                	ret
ffffffffc02043ae:	6442                	ld	s0,16(sp)
ffffffffc02043b0:	60e2                	ld	ra,24(sp)
ffffffffc02043b2:	64a2                	ld	s1,8(sp)
ffffffffc02043b4:	6902                	ld	s2,0(sp)
ffffffffc02043b6:	6105                	addi	sp,sp,32
        intr_enable();
ffffffffc02043b8:	a1cfc06f          	j	ffffffffc02005d4 <intr_enable>
        intr_disable();
ffffffffc02043bc:	a1efc0ef          	jal	ra,ffffffffc02005da <intr_disable>
        return 1;
ffffffffc02043c0:	4905                	li	s2,1
ffffffffc02043c2:	bf65                	j	ffffffffc020437a <proc_run+0x24>

ffffffffc02043c4 <find_proc>:
    if (0 < pid && pid < MAX_PID) {
ffffffffc02043c4:	0005071b          	sext.w	a4,a0
ffffffffc02043c8:	6789                	lui	a5,0x2
ffffffffc02043ca:	fff7069b          	addiw	a3,a4,-1
ffffffffc02043ce:	17f9                	addi	a5,a5,-2
ffffffffc02043d0:	04d7e063          	bltu	a5,a3,ffffffffc0204410 <find_proc+0x4c>
find_proc(int pid) {
ffffffffc02043d4:	1141                	addi	sp,sp,-16
ffffffffc02043d6:	e022                	sd	s0,0(sp)
        list_entry_t *list = hash_list + pid_hashfn(pid), *le = list;
ffffffffc02043d8:	45a9                	li	a1,10
ffffffffc02043da:	842a                	mv	s0,a0
ffffffffc02043dc:	853a                	mv	a0,a4
find_proc(int pid) {
ffffffffc02043de:	e406                	sd	ra,8(sp)
        list_entry_t *list = hash_list + pid_hashfn(pid), *le = list;
ffffffffc02043e0:	2a9000ef          	jal	ra,ffffffffc0204e88 <hash32>
ffffffffc02043e4:	02051693          	slli	a3,a0,0x20
ffffffffc02043e8:	82f1                	srli	a3,a3,0x1c
ffffffffc02043ea:	0000d517          	auipc	a0,0xd
ffffffffc02043ee:	07650513          	addi	a0,a0,118 # ffffffffc0211460 <hash_list>
ffffffffc02043f2:	96aa                	add	a3,a3,a0
ffffffffc02043f4:	87b6                	mv	a5,a3
        while ((le = list_next(le)) != list) {
ffffffffc02043f6:	a029                	j	ffffffffc0204400 <find_proc+0x3c>
            if (proc->pid == pid) {
ffffffffc02043f8:	f2c7a703          	lw	a4,-212(a5) # 1f2c <BASE_ADDRESS-0xffffffffc01fe0d4>
ffffffffc02043fc:	00870c63          	beq	a4,s0,ffffffffc0204414 <find_proc+0x50>
    return listelm->next;
ffffffffc0204400:	679c                	ld	a5,8(a5)
        while ((le = list_next(le)) != list) {
ffffffffc0204402:	fef69be3          	bne	a3,a5,ffffffffc02043f8 <find_proc+0x34>
}
ffffffffc0204406:	60a2                	ld	ra,8(sp)
ffffffffc0204408:	6402                	ld	s0,0(sp)
    return NULL;
ffffffffc020440a:	4501                	li	a0,0
}
ffffffffc020440c:	0141                	addi	sp,sp,16
ffffffffc020440e:	8082                	ret
    return NULL;
ffffffffc0204410:	4501                	li	a0,0
}
ffffffffc0204412:	8082                	ret
ffffffffc0204414:	60a2                	ld	ra,8(sp)
ffffffffc0204416:	6402                	ld	s0,0(sp)
            struct proc_struct *proc = le2proc(le, hash_link);
ffffffffc0204418:	f2878513          	addi	a0,a5,-216
}
ffffffffc020441c:	0141                	addi	sp,sp,16
ffffffffc020441e:	8082                	ret

ffffffffc0204420 <do_fork>:
do_fork(uint32_t clone_flags, uintptr_t stack, struct trapframe *tf) {
ffffffffc0204420:	7179                	addi	sp,sp,-48
ffffffffc0204422:	e84a                	sd	s2,16(sp)
    if (nr_process >= MAX_PROCESS) {
ffffffffc0204424:	00011917          	auipc	s2,0x11
ffffffffc0204428:	0a490913          	addi	s2,s2,164 # ffffffffc02154c8 <nr_process>
ffffffffc020442c:	00092703          	lw	a4,0(s2)
do_fork(uint32_t clone_flags, uintptr_t stack, struct trapframe *tf) {
ffffffffc0204430:	f406                	sd	ra,40(sp)
ffffffffc0204432:	f022                	sd	s0,32(sp)
ffffffffc0204434:	ec26                	sd	s1,24(sp)
ffffffffc0204436:	e44e                	sd	s3,8(sp)
ffffffffc0204438:	e052                	sd	s4,0(sp)
    if (nr_process >= MAX_PROCESS) {
ffffffffc020443a:	6785                	lui	a5,0x1
ffffffffc020443c:	1cf75c63          	ble	a5,a4,ffffffffc0204614 <do_fork+0x1f4>
ffffffffc0204440:	8a2e                	mv	s4,a1
ffffffffc0204442:	84b2                	mv	s1,a2
    proc->parent = current;
ffffffffc0204444:	00011997          	auipc	s3,0x11
ffffffffc0204448:	06c98993          	addi	s3,s3,108 # ffffffffc02154b0 <current>
    proc= alloc_proc();
ffffffffc020444c:	debff0ef          	jal	ra,ffffffffc0204236 <alloc_proc>
    proc->parent = current;
ffffffffc0204450:	0009b783          	ld	a5,0(s3)
    proc= alloc_proc();
ffffffffc0204454:	842a                	mv	s0,a0
    struct Page *page = alloc_pages(KSTACKPAGE);
ffffffffc0204456:	4509                	li	a0,2
    proc->parent = current;
ffffffffc0204458:	f01c                	sd	a5,32(s0)
    struct Page *page = alloc_pages(KSTACKPAGE);
ffffffffc020445a:	f60fc0ef          	jal	ra,ffffffffc0200bba <alloc_pages>
    if (page != NULL) {
ffffffffc020445e:	1a050663          	beqz	a0,ffffffffc020460a <do_fork+0x1ea>
    return page - pages + nbase;
ffffffffc0204462:	00011797          	auipc	a5,0x11
ffffffffc0204466:	08e78793          	addi	a5,a5,142 # ffffffffc02154f0 <pages>
ffffffffc020446a:	6394                	ld	a3,0(a5)
ffffffffc020446c:	00003797          	auipc	a5,0x3
ffffffffc0204470:	b3478793          	addi	a5,a5,-1228 # ffffffffc0206fa0 <nbase>
    return KADDR(page2pa(page));
ffffffffc0204474:	00011717          	auipc	a4,0x11
ffffffffc0204478:	01470713          	addi	a4,a4,20 # ffffffffc0215488 <npage>
    return page - pages + nbase;
ffffffffc020447c:	40d506b3          	sub	a3,a0,a3
ffffffffc0204480:	6388                	ld	a0,0(a5)
ffffffffc0204482:	8699                	srai	a3,a3,0x6
    return KADDR(page2pa(page));
ffffffffc0204484:	57fd                	li	a5,-1
ffffffffc0204486:	6318                	ld	a4,0(a4)
    return page - pages + nbase;
ffffffffc0204488:	96aa                	add	a3,a3,a0
    return KADDR(page2pa(page));
ffffffffc020448a:	83b1                	srli	a5,a5,0xc
ffffffffc020448c:	8ff5                	and	a5,a5,a3
    return page2ppn(page) << PGSHIFT;
ffffffffc020448e:	06b2                	slli	a3,a3,0xc
    return KADDR(page2pa(page));
ffffffffc0204490:	1ae7f463          	bleu	a4,a5,ffffffffc0204638 <do_fork+0x218>
    assert(current->mm == NULL);
ffffffffc0204494:	0009b783          	ld	a5,0(s3)
ffffffffc0204498:	00011717          	auipc	a4,0x11
ffffffffc020449c:	04870713          	addi	a4,a4,72 # ffffffffc02154e0 <va_pa_offset>
ffffffffc02044a0:	6318                	ld	a4,0(a4)
ffffffffc02044a2:	779c                	ld	a5,40(a5)
ffffffffc02044a4:	96ba                	add	a3,a3,a4
        proc->kstack = (uintptr_t)page2kva(page);
ffffffffc02044a6:	e814                	sd	a3,16(s0)
    assert(current->mm == NULL);
ffffffffc02044a8:	16079863          	bnez	a5,ffffffffc0204618 <do_fork+0x1f8>
    proc->tf = (struct trapframe *)(proc->kstack + KSTACKSIZE - sizeof(struct trapframe));
ffffffffc02044ac:	6789                	lui	a5,0x2
ffffffffc02044ae:	ee078793          	addi	a5,a5,-288 # 1ee0 <BASE_ADDRESS-0xffffffffc01fe120>
ffffffffc02044b2:	96be                	add	a3,a3,a5
    *(proc->tf) = *tf;
ffffffffc02044b4:	8626                	mv	a2,s1
    proc->tf = (struct trapframe *)(proc->kstack + KSTACKSIZE - sizeof(struct trapframe));
ffffffffc02044b6:	f054                	sd	a3,160(s0)
    *(proc->tf) = *tf;
ffffffffc02044b8:	87b6                	mv	a5,a3
ffffffffc02044ba:	12048893          	addi	a7,s1,288
ffffffffc02044be:	00063803          	ld	a6,0(a2)
ffffffffc02044c2:	6608                	ld	a0,8(a2)
ffffffffc02044c4:	6a0c                	ld	a1,16(a2)
ffffffffc02044c6:	6e18                	ld	a4,24(a2)
ffffffffc02044c8:	0107b023          	sd	a6,0(a5)
ffffffffc02044cc:	e788                	sd	a0,8(a5)
ffffffffc02044ce:	eb8c                	sd	a1,16(a5)
ffffffffc02044d0:	ef98                	sd	a4,24(a5)
ffffffffc02044d2:	02060613          	addi	a2,a2,32
ffffffffc02044d6:	02078793          	addi	a5,a5,32
ffffffffc02044da:	ff1612e3          	bne	a2,a7,ffffffffc02044be <do_fork+0x9e>
    proc->tf->gpr.a0 = 0;
ffffffffc02044de:	0406b823          	sd	zero,80(a3)
    proc->tf->gpr.sp = (esp == 0) ? (uintptr_t)proc->tf : esp;
ffffffffc02044e2:	100a0663          	beqz	s4,ffffffffc02045ee <do_fork+0x1ce>
    if (++ last_pid >= MAX_PID) {
ffffffffc02044e6:	00006797          	auipc	a5,0x6
ffffffffc02044ea:	b7278793          	addi	a5,a5,-1166 # ffffffffc020a058 <last_pid.1575>
ffffffffc02044ee:	439c                	lw	a5,0(a5)
    proc->tf->gpr.sp = (esp == 0) ? (uintptr_t)proc->tf : esp;
ffffffffc02044f0:	0146b823          	sd	s4,16(a3)
    proc->context.ra = (uintptr_t)forkret;
ffffffffc02044f4:	00000717          	auipc	a4,0x0
ffffffffc02044f8:	da670713          	addi	a4,a4,-602 # ffffffffc020429a <forkret>
    if (++ last_pid >= MAX_PID) {
ffffffffc02044fc:	0017851b          	addiw	a0,a5,1
    proc->context.ra = (uintptr_t)forkret;
ffffffffc0204500:	f818                	sd	a4,48(s0)
    proc->context.sp = (uintptr_t)(proc->tf);
ffffffffc0204502:	fc14                	sd	a3,56(s0)
    if (++ last_pid >= MAX_PID) {
ffffffffc0204504:	00006717          	auipc	a4,0x6
ffffffffc0204508:	b4a72a23          	sw	a0,-1196(a4) # ffffffffc020a058 <last_pid.1575>
ffffffffc020450c:	6789                	lui	a5,0x2
ffffffffc020450e:	0ef55263          	ble	a5,a0,ffffffffc02045f2 <do_fork+0x1d2>
    if (last_pid >= next_safe) {
ffffffffc0204512:	00006797          	auipc	a5,0x6
ffffffffc0204516:	b4a78793          	addi	a5,a5,-1206 # ffffffffc020a05c <next_safe.1574>
ffffffffc020451a:	439c                	lw	a5,0(a5)
ffffffffc020451c:	00011497          	auipc	s1,0x11
ffffffffc0204520:	0d448493          	addi	s1,s1,212 # ffffffffc02155f0 <proc_list>
ffffffffc0204524:	06f54063          	blt	a0,a5,ffffffffc0204584 <do_fork+0x164>
        next_safe = MAX_PID;
ffffffffc0204528:	6789                	lui	a5,0x2
ffffffffc020452a:	00006717          	auipc	a4,0x6
ffffffffc020452e:	b2f72923          	sw	a5,-1230(a4) # ffffffffc020a05c <next_safe.1574>
ffffffffc0204532:	4581                	li	a1,0
ffffffffc0204534:	87aa                	mv	a5,a0
ffffffffc0204536:	00011497          	auipc	s1,0x11
ffffffffc020453a:	0ba48493          	addi	s1,s1,186 # ffffffffc02155f0 <proc_list>
    repeat:
ffffffffc020453e:	6889                	lui	a7,0x2
ffffffffc0204540:	882e                	mv	a6,a1
ffffffffc0204542:	6609                	lui	a2,0x2
        le = list;
ffffffffc0204544:	00011697          	auipc	a3,0x11
ffffffffc0204548:	0ac68693          	addi	a3,a3,172 # ffffffffc02155f0 <proc_list>
ffffffffc020454c:	6694                	ld	a3,8(a3)
        while ((le = list_next(le)) != list) {
ffffffffc020454e:	00968f63          	beq	a3,s1,ffffffffc020456c <do_fork+0x14c>
            if (proc->pid == last_pid) {
ffffffffc0204552:	f3c6a703          	lw	a4,-196(a3)
ffffffffc0204556:	08e78763          	beq	a5,a4,ffffffffc02045e4 <do_fork+0x1c4>
            else if (proc->pid > last_pid && next_safe > proc->pid) {
ffffffffc020455a:	fee7d9e3          	ble	a4,a5,ffffffffc020454c <do_fork+0x12c>
ffffffffc020455e:	fec757e3          	ble	a2,a4,ffffffffc020454c <do_fork+0x12c>
ffffffffc0204562:	6694                	ld	a3,8(a3)
ffffffffc0204564:	863a                	mv	a2,a4
ffffffffc0204566:	4805                	li	a6,1
        while ((le = list_next(le)) != list) {
ffffffffc0204568:	fe9695e3          	bne	a3,s1,ffffffffc0204552 <do_fork+0x132>
ffffffffc020456c:	c591                	beqz	a1,ffffffffc0204578 <do_fork+0x158>
ffffffffc020456e:	00006717          	auipc	a4,0x6
ffffffffc0204572:	aef72523          	sw	a5,-1302(a4) # ffffffffc020a058 <last_pid.1575>
ffffffffc0204576:	853e                	mv	a0,a5
ffffffffc0204578:	00080663          	beqz	a6,ffffffffc0204584 <do_fork+0x164>
ffffffffc020457c:	00006797          	auipc	a5,0x6
ffffffffc0204580:	aec7a023          	sw	a2,-1312(a5) # ffffffffc020a05c <next_safe.1574>
    list_add(hash_list + pid_hashfn(proc->pid), &(proc->hash_link));
ffffffffc0204584:	45a9                	li	a1,10
    proc->pid =get_pid();
ffffffffc0204586:	c048                	sw	a0,4(s0)
    list_add(hash_list + pid_hashfn(proc->pid), &(proc->hash_link));
ffffffffc0204588:	2501                	sext.w	a0,a0
ffffffffc020458a:	0ff000ef          	jal	ra,ffffffffc0204e88 <hash32>
ffffffffc020458e:	1502                	slli	a0,a0,0x20
ffffffffc0204590:	0000d797          	auipc	a5,0xd
ffffffffc0204594:	ed078793          	addi	a5,a5,-304 # ffffffffc0211460 <hash_list>
ffffffffc0204598:	8171                	srli	a0,a0,0x1c
ffffffffc020459a:	953e                	add	a0,a0,a5
    __list_add(elm, listelm, listelm->next);
ffffffffc020459c:	6518                	ld	a4,8(a0)
ffffffffc020459e:	0d840793          	addi	a5,s0,216
ffffffffc02045a2:	6494                	ld	a3,8(s1)
    prev->next = next->prev = elm;
ffffffffc02045a4:	e31c                	sd	a5,0(a4)
ffffffffc02045a6:	e51c                	sd	a5,8(a0)
    nr_process++;
ffffffffc02045a8:	00092783          	lw	a5,0(s2)
    elm->next = next;
ffffffffc02045ac:	f078                	sd	a4,224(s0)
    elm->prev = prev;
ffffffffc02045ae:	ec68                	sd	a0,216(s0)
    list_add(&proc_list,&(proc->list_link));
ffffffffc02045b0:	0c840713          	addi	a4,s0,200
    prev->next = next->prev = elm;
ffffffffc02045b4:	e298                	sd	a4,0(a3)
    nr_process++;
ffffffffc02045b6:	2785                	addiw	a5,a5,1
    elm->next = next;
ffffffffc02045b8:	e874                	sd	a3,208(s0)
    wakeup_proc(proc);
ffffffffc02045ba:	8522                	mv	a0,s0
    elm->prev = prev;
ffffffffc02045bc:	e464                	sd	s1,200(s0)
    prev->next = next->prev = elm;
ffffffffc02045be:	00011697          	auipc	a3,0x11
ffffffffc02045c2:	02e6bd23          	sd	a4,58(a3) # ffffffffc02155f8 <proc_list+0x8>
    nr_process++;
ffffffffc02045c6:	00011717          	auipc	a4,0x11
ffffffffc02045ca:	f0f72123          	sw	a5,-254(a4) # ffffffffc02154c8 <nr_process>
    wakeup_proc(proc);
ffffffffc02045ce:	2fe000ef          	jal	ra,ffffffffc02048cc <wakeup_proc>
    ret = proc->pid;
ffffffffc02045d2:	4048                	lw	a0,4(s0)
}
ffffffffc02045d4:	70a2                	ld	ra,40(sp)
ffffffffc02045d6:	7402                	ld	s0,32(sp)
ffffffffc02045d8:	64e2                	ld	s1,24(sp)
ffffffffc02045da:	6942                	ld	s2,16(sp)
ffffffffc02045dc:	69a2                	ld	s3,8(sp)
ffffffffc02045de:	6a02                	ld	s4,0(sp)
ffffffffc02045e0:	6145                	addi	sp,sp,48
ffffffffc02045e2:	8082                	ret
                if (++ last_pid >= next_safe) {
ffffffffc02045e4:	2785                	addiw	a5,a5,1
ffffffffc02045e6:	00c7dd63          	ble	a2,a5,ffffffffc0204600 <do_fork+0x1e0>
ffffffffc02045ea:	4585                	li	a1,1
ffffffffc02045ec:	b785                	j	ffffffffc020454c <do_fork+0x12c>
    proc->tf->gpr.sp = (esp == 0) ? (uintptr_t)proc->tf : esp;
ffffffffc02045ee:	8a36                	mv	s4,a3
ffffffffc02045f0:	bddd                	j	ffffffffc02044e6 <do_fork+0xc6>
        last_pid = 1;
ffffffffc02045f2:	4785                	li	a5,1
ffffffffc02045f4:	00006717          	auipc	a4,0x6
ffffffffc02045f8:	a6f72223          	sw	a5,-1436(a4) # ffffffffc020a058 <last_pid.1575>
ffffffffc02045fc:	4505                	li	a0,1
ffffffffc02045fe:	b72d                	j	ffffffffc0204528 <do_fork+0x108>
                    if (last_pid >= MAX_PID) {
ffffffffc0204600:	0117c363          	blt	a5,a7,ffffffffc0204606 <do_fork+0x1e6>
                        last_pid = 1;
ffffffffc0204604:	4785                	li	a5,1
                    goto repeat;
ffffffffc0204606:	4585                	li	a1,1
ffffffffc0204608:	bf25                	j	ffffffffc0204540 <do_fork+0x120>
    kfree(proc);
ffffffffc020460a:	8522                	mv	a0,s0
ffffffffc020460c:	9f7fe0ef          	jal	ra,ffffffffc0203002 <kfree>
    ret = -E_NO_MEM;
ffffffffc0204610:	5571                	li	a0,-4
    goto fork_out;
ffffffffc0204612:	b7c9                	j	ffffffffc02045d4 <do_fork+0x1b4>
    int ret = -E_NO_FREE_PROC;
ffffffffc0204614:	556d                	li	a0,-5
ffffffffc0204616:	bf7d                	j	ffffffffc02045d4 <do_fork+0x1b4>
    assert(current->mm == NULL);
ffffffffc0204618:	00002697          	auipc	a3,0x2
ffffffffc020461c:	5a868693          	addi	a3,a3,1448 # ffffffffc0206bc0 <default_pmm_manager+0xc0>
ffffffffc0204620:	00001617          	auipc	a2,0x1
ffffffffc0204624:	36860613          	addi	a2,a2,872 # ffffffffc0205988 <commands+0x998>
ffffffffc0204628:	11e00593          	li	a1,286
ffffffffc020462c:	00002517          	auipc	a0,0x2
ffffffffc0204630:	5ac50513          	addi	a0,a0,1452 # ffffffffc0206bd8 <default_pmm_manager+0xd8>
ffffffffc0204634:	ba3fb0ef          	jal	ra,ffffffffc02001d6 <__panic>
ffffffffc0204638:	00001617          	auipc	a2,0x1
ffffffffc020463c:	1f860613          	addi	a2,a2,504 # ffffffffc0205830 <commands+0x840>
ffffffffc0204640:	06900593          	li	a1,105
ffffffffc0204644:	00001517          	auipc	a0,0x1
ffffffffc0204648:	24450513          	addi	a0,a0,580 # ffffffffc0205888 <commands+0x898>
ffffffffc020464c:	b8bfb0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc0204650 <kernel_thread>:
kernel_thread(int (*fn)(void *), void *arg, uint32_t clone_flags) {
ffffffffc0204650:	7129                	addi	sp,sp,-320
ffffffffc0204652:	fa22                	sd	s0,304(sp)
ffffffffc0204654:	f626                	sd	s1,296(sp)
ffffffffc0204656:	f24a                	sd	s2,288(sp)
ffffffffc0204658:	84ae                	mv	s1,a1
ffffffffc020465a:	892a                	mv	s2,a0
ffffffffc020465c:	8432                	mv	s0,a2
    memset(&tf, 0, sizeof(struct trapframe));
ffffffffc020465e:	4581                	li	a1,0
ffffffffc0204660:	12000613          	li	a2,288
ffffffffc0204664:	850a                	mv	a0,sp
kernel_thread(int (*fn)(void *), void *arg, uint32_t clone_flags) {
ffffffffc0204666:	fe06                	sd	ra,312(sp)
    memset(&tf, 0, sizeof(struct trapframe));
ffffffffc0204668:	3ce000ef          	jal	ra,ffffffffc0204a36 <memset>
    tf.gpr.s0 = (uintptr_t)fn;
ffffffffc020466c:	e0ca                	sd	s2,64(sp)
    tf.gpr.s1 = (uintptr_t)arg;
ffffffffc020466e:	e4a6                	sd	s1,72(sp)
    tf.status = (read_csr(sstatus) | SSTATUS_SPP | SSTATUS_SPIE) & ~SSTATUS_SIE;
ffffffffc0204670:	100027f3          	csrr	a5,sstatus
ffffffffc0204674:	edd7f793          	andi	a5,a5,-291
ffffffffc0204678:	1207e793          	ori	a5,a5,288
ffffffffc020467c:	e23e                	sd	a5,256(sp)
    return do_fork(clone_flags | CLONE_VM, 0, &tf);
ffffffffc020467e:	860a                	mv	a2,sp
ffffffffc0204680:	10046513          	ori	a0,s0,256
    tf.epc = (uintptr_t)kernel_thread_entry;
ffffffffc0204684:	00000797          	auipc	a5,0x0
ffffffffc0204688:	baa78793          	addi	a5,a5,-1110 # ffffffffc020422e <kernel_thread_entry>
    return do_fork(clone_flags | CLONE_VM, 0, &tf);
ffffffffc020468c:	4581                	li	a1,0
    tf.epc = (uintptr_t)kernel_thread_entry;
ffffffffc020468e:	e63e                	sd	a5,264(sp)
    return do_fork(clone_flags | CLONE_VM, 0, &tf);
ffffffffc0204690:	d91ff0ef          	jal	ra,ffffffffc0204420 <do_fork>
}
ffffffffc0204694:	70f2                	ld	ra,312(sp)
ffffffffc0204696:	7452                	ld	s0,304(sp)
ffffffffc0204698:	74b2                	ld	s1,296(sp)
ffffffffc020469a:	7912                	ld	s2,288(sp)
ffffffffc020469c:	6131                	addi	sp,sp,320
ffffffffc020469e:	8082                	ret

ffffffffc02046a0 <do_exit>:
do_exit(int error_code) {
ffffffffc02046a0:	1141                	addi	sp,sp,-16
    panic("process exit!!.\n");
ffffffffc02046a2:	00002617          	auipc	a2,0x2
ffffffffc02046a6:	50660613          	addi	a2,a2,1286 # ffffffffc0206ba8 <default_pmm_manager+0xa8>
ffffffffc02046aa:	18d00593          	li	a1,397
ffffffffc02046ae:	00002517          	auipc	a0,0x2
ffffffffc02046b2:	52a50513          	addi	a0,a0,1322 # ffffffffc0206bd8 <default_pmm_manager+0xd8>
do_exit(int error_code) {
ffffffffc02046b6:	e406                	sd	ra,8(sp)
    panic("process exit!!.\n");
ffffffffc02046b8:	b1ffb0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc02046bc <proc_init>:
    elm->prev = elm->next = elm;
ffffffffc02046bc:	00011797          	auipc	a5,0x11
ffffffffc02046c0:	f3478793          	addi	a5,a5,-204 # ffffffffc02155f0 <proc_list>

// proc_init - set up the first kernel thread idleproc "idle" by itself and 
//           - create the second kernel thread init_main
void
proc_init(void) {
ffffffffc02046c4:	1101                	addi	sp,sp,-32
ffffffffc02046c6:	00011717          	auipc	a4,0x11
ffffffffc02046ca:	f2f73923          	sd	a5,-206(a4) # ffffffffc02155f8 <proc_list+0x8>
ffffffffc02046ce:	00011717          	auipc	a4,0x11
ffffffffc02046d2:	f2f73123          	sd	a5,-222(a4) # ffffffffc02155f0 <proc_list>
ffffffffc02046d6:	ec06                	sd	ra,24(sp)
ffffffffc02046d8:	e822                	sd	s0,16(sp)
ffffffffc02046da:	e426                	sd	s1,8(sp)
ffffffffc02046dc:	e04a                	sd	s2,0(sp)
ffffffffc02046de:	0000d797          	auipc	a5,0xd
ffffffffc02046e2:	d8278793          	addi	a5,a5,-638 # ffffffffc0211460 <hash_list>
ffffffffc02046e6:	00011717          	auipc	a4,0x11
ffffffffc02046ea:	d7a70713          	addi	a4,a4,-646 # ffffffffc0215460 <name.1565>
ffffffffc02046ee:	e79c                	sd	a5,8(a5)
ffffffffc02046f0:	e39c                	sd	a5,0(a5)
ffffffffc02046f2:	07c1                	addi	a5,a5,16
    int i;

    list_init(&proc_list);
    for (i = 0; i < HASH_LIST_SIZE; i ++) {
ffffffffc02046f4:	fee79de3          	bne	a5,a4,ffffffffc02046ee <proc_init+0x32>
        list_init(hash_list + i);
    }

    if ((idleproc = alloc_proc()) == NULL) {
ffffffffc02046f8:	b3fff0ef          	jal	ra,ffffffffc0204236 <alloc_proc>
ffffffffc02046fc:	00011797          	auipc	a5,0x11
ffffffffc0204700:	daa7be23          	sd	a0,-580(a5) # ffffffffc02154b8 <idleproc>
ffffffffc0204704:	00011417          	auipc	s0,0x11
ffffffffc0204708:	db440413          	addi	s0,s0,-588 # ffffffffc02154b8 <idleproc>
ffffffffc020470c:	12050a63          	beqz	a0,ffffffffc0204840 <proc_init+0x184>
        panic("cannot alloc idleproc.\n");
    }

    // check the proc structure
    int *context_mem = (int*) kmalloc(sizeof(struct context));
ffffffffc0204710:	07000513          	li	a0,112
ffffffffc0204714:	833fe0ef          	jal	ra,ffffffffc0202f46 <kmalloc>
    memset(context_mem, 0, sizeof(struct context));
ffffffffc0204718:	07000613          	li	a2,112
ffffffffc020471c:	4581                	li	a1,0
    int *context_mem = (int*) kmalloc(sizeof(struct context));
ffffffffc020471e:	84aa                	mv	s1,a0
    memset(context_mem, 0, sizeof(struct context));
ffffffffc0204720:	316000ef          	jal	ra,ffffffffc0204a36 <memset>
    int context_init_flag = memcmp(&(idleproc->context), context_mem, sizeof(struct context));
ffffffffc0204724:	6008                	ld	a0,0(s0)
ffffffffc0204726:	85a6                	mv	a1,s1
ffffffffc0204728:	07000613          	li	a2,112
ffffffffc020472c:	03050513          	addi	a0,a0,48
ffffffffc0204730:	330000ef          	jal	ra,ffffffffc0204a60 <memcmp>
ffffffffc0204734:	892a                	mv	s2,a0

    int *proc_name_mem = (int*) kmalloc(PROC_NAME_LEN);
ffffffffc0204736:	453d                	li	a0,15
ffffffffc0204738:	80ffe0ef          	jal	ra,ffffffffc0202f46 <kmalloc>
    memset(proc_name_mem, 0, PROC_NAME_LEN);
ffffffffc020473c:	463d                	li	a2,15
ffffffffc020473e:	4581                	li	a1,0
    int *proc_name_mem = (int*) kmalloc(PROC_NAME_LEN);
ffffffffc0204740:	84aa                	mv	s1,a0
    memset(proc_name_mem, 0, PROC_NAME_LEN);
ffffffffc0204742:	2f4000ef          	jal	ra,ffffffffc0204a36 <memset>
    int proc_name_flag = memcmp(&(idleproc->name), proc_name_mem, PROC_NAME_LEN);
ffffffffc0204746:	6008                	ld	a0,0(s0)
ffffffffc0204748:	463d                	li	a2,15
ffffffffc020474a:	85a6                	mv	a1,s1
ffffffffc020474c:	0b450513          	addi	a0,a0,180
ffffffffc0204750:	310000ef          	jal	ra,ffffffffc0204a60 <memcmp>

    if(idleproc->cr3 == boot_cr3 && idleproc->tf == NULL && !context_init_flag
ffffffffc0204754:	601c                	ld	a5,0(s0)
ffffffffc0204756:	00011717          	auipc	a4,0x11
ffffffffc020475a:	d9270713          	addi	a4,a4,-622 # ffffffffc02154e8 <boot_cr3>
ffffffffc020475e:	6318                	ld	a4,0(a4)
ffffffffc0204760:	77d4                	ld	a3,168(a5)
ffffffffc0204762:	08e68e63          	beq	a3,a4,ffffffffc02047fe <proc_init+0x142>
        cprintf("alloc_proc() correct!\n");

    }
    
    idleproc->pid = 0;
    idleproc->state = PROC_RUNNABLE;
ffffffffc0204766:	4709                	li	a4,2
ffffffffc0204768:	e398                	sd	a4,0(a5)
    idleproc->kstack = (uintptr_t)bootstack;
ffffffffc020476a:	00003717          	auipc	a4,0x3
ffffffffc020476e:	89670713          	addi	a4,a4,-1898 # ffffffffc0207000 <bootstack>
ffffffffc0204772:	eb98                	sd	a4,16(a5)
    idleproc->need_resched = 1;
ffffffffc0204774:	4705                	li	a4,1
ffffffffc0204776:	cf98                	sw	a4,24(a5)
    set_proc_name(idleproc, "idle");
ffffffffc0204778:	00002597          	auipc	a1,0x2
ffffffffc020477c:	50058593          	addi	a1,a1,1280 # ffffffffc0206c78 <default_pmm_manager+0x178>
ffffffffc0204780:	853e                	mv	a0,a5
ffffffffc0204782:	b29ff0ef          	jal	ra,ffffffffc02042aa <set_proc_name>
    nr_process ++;
ffffffffc0204786:	00011797          	auipc	a5,0x11
ffffffffc020478a:	d4278793          	addi	a5,a5,-702 # ffffffffc02154c8 <nr_process>
ffffffffc020478e:	439c                	lw	a5,0(a5)

    current = idleproc;
ffffffffc0204790:	6018                	ld	a4,0(s0)

    int pid = kernel_thread(init_main, "Hello world!!", 0);
ffffffffc0204792:	4601                	li	a2,0
    nr_process ++;
ffffffffc0204794:	2785                	addiw	a5,a5,1
    int pid = kernel_thread(init_main, "Hello world!!", 0);
ffffffffc0204796:	00002597          	auipc	a1,0x2
ffffffffc020479a:	4ea58593          	addi	a1,a1,1258 # ffffffffc0206c80 <default_pmm_manager+0x180>
ffffffffc020479e:	00000517          	auipc	a0,0x0
ffffffffc02047a2:	b6650513          	addi	a0,a0,-1178 # ffffffffc0204304 <init_main>
    nr_process ++;
ffffffffc02047a6:	00011697          	auipc	a3,0x11
ffffffffc02047aa:	d2f6a123          	sw	a5,-734(a3) # ffffffffc02154c8 <nr_process>
    current = idleproc;
ffffffffc02047ae:	00011797          	auipc	a5,0x11
ffffffffc02047b2:	d0e7b123          	sd	a4,-766(a5) # ffffffffc02154b0 <current>
    int pid = kernel_thread(init_main, "Hello world!!", 0);
ffffffffc02047b6:	e9bff0ef          	jal	ra,ffffffffc0204650 <kernel_thread>
    if (pid <= 0) {
ffffffffc02047ba:	0ca05f63          	blez	a0,ffffffffc0204898 <proc_init+0x1dc>
        panic("create init_main failed.\n");
    }

    initproc = find_proc(pid);
ffffffffc02047be:	c07ff0ef          	jal	ra,ffffffffc02043c4 <find_proc>
    set_proc_name(initproc, "init");
ffffffffc02047c2:	00002597          	auipc	a1,0x2
ffffffffc02047c6:	4ee58593          	addi	a1,a1,1262 # ffffffffc0206cb0 <default_pmm_manager+0x1b0>
    initproc = find_proc(pid);
ffffffffc02047ca:	00011797          	auipc	a5,0x11
ffffffffc02047ce:	cea7bb23          	sd	a0,-778(a5) # ffffffffc02154c0 <initproc>
    set_proc_name(initproc, "init");
ffffffffc02047d2:	ad9ff0ef          	jal	ra,ffffffffc02042aa <set_proc_name>

    assert(idleproc != NULL && idleproc->pid == 0);
ffffffffc02047d6:	601c                	ld	a5,0(s0)
ffffffffc02047d8:	c3c5                	beqz	a5,ffffffffc0204878 <proc_init+0x1bc>
ffffffffc02047da:	43dc                	lw	a5,4(a5)
ffffffffc02047dc:	efd1                	bnez	a5,ffffffffc0204878 <proc_init+0x1bc>
    assert(initproc != NULL && initproc->pid == 1);
ffffffffc02047de:	00011797          	auipc	a5,0x11
ffffffffc02047e2:	ce278793          	addi	a5,a5,-798 # ffffffffc02154c0 <initproc>
ffffffffc02047e6:	639c                	ld	a5,0(a5)
ffffffffc02047e8:	cba5                	beqz	a5,ffffffffc0204858 <proc_init+0x19c>
ffffffffc02047ea:	43d8                	lw	a4,4(a5)
ffffffffc02047ec:	4785                	li	a5,1
ffffffffc02047ee:	06f71563          	bne	a4,a5,ffffffffc0204858 <proc_init+0x19c>
}
ffffffffc02047f2:	60e2                	ld	ra,24(sp)
ffffffffc02047f4:	6442                	ld	s0,16(sp)
ffffffffc02047f6:	64a2                	ld	s1,8(sp)
ffffffffc02047f8:	6902                	ld	s2,0(sp)
ffffffffc02047fa:	6105                	addi	sp,sp,32
ffffffffc02047fc:	8082                	ret
    if(idleproc->cr3 == boot_cr3 && idleproc->tf == NULL && !context_init_flag
ffffffffc02047fe:	73d8                	ld	a4,160(a5)
ffffffffc0204800:	f33d                	bnez	a4,ffffffffc0204766 <proc_init+0xaa>
ffffffffc0204802:	f60912e3          	bnez	s2,ffffffffc0204766 <proc_init+0xaa>
        && idleproc->state == PROC_UNINIT && idleproc->pid == -1 && idleproc->runs == 0
ffffffffc0204806:	6394                	ld	a3,0(a5)
ffffffffc0204808:	577d                	li	a4,-1
ffffffffc020480a:	1702                	slli	a4,a4,0x20
ffffffffc020480c:	f4e69de3          	bne	a3,a4,ffffffffc0204766 <proc_init+0xaa>
ffffffffc0204810:	4798                	lw	a4,8(a5)
ffffffffc0204812:	fb31                	bnez	a4,ffffffffc0204766 <proc_init+0xaa>
        && idleproc->kstack == 0 && idleproc->need_resched == 0 && idleproc->parent == NULL
ffffffffc0204814:	6b98                	ld	a4,16(a5)
ffffffffc0204816:	fb21                	bnez	a4,ffffffffc0204766 <proc_init+0xaa>
ffffffffc0204818:	4f98                	lw	a4,24(a5)
ffffffffc020481a:	2701                	sext.w	a4,a4
ffffffffc020481c:	f729                	bnez	a4,ffffffffc0204766 <proc_init+0xaa>
ffffffffc020481e:	7398                	ld	a4,32(a5)
ffffffffc0204820:	f339                	bnez	a4,ffffffffc0204766 <proc_init+0xaa>
        && idleproc->mm == NULL && idleproc->flags == 0 && !proc_name_flag
ffffffffc0204822:	7798                	ld	a4,40(a5)
ffffffffc0204824:	f329                	bnez	a4,ffffffffc0204766 <proc_init+0xaa>
ffffffffc0204826:	0b07a703          	lw	a4,176(a5)
ffffffffc020482a:	8f49                	or	a4,a4,a0
ffffffffc020482c:	2701                	sext.w	a4,a4
ffffffffc020482e:	ff05                	bnez	a4,ffffffffc0204766 <proc_init+0xaa>
        cprintf("alloc_proc() correct!\n");
ffffffffc0204830:	00002517          	auipc	a0,0x2
ffffffffc0204834:	43050513          	addi	a0,a0,1072 # ffffffffc0206c60 <default_pmm_manager+0x160>
ffffffffc0204838:	899fb0ef          	jal	ra,ffffffffc02000d0 <cprintf>
ffffffffc020483c:	601c                	ld	a5,0(s0)
ffffffffc020483e:	b725                	j	ffffffffc0204766 <proc_init+0xaa>
        panic("cannot alloc idleproc.\n");
ffffffffc0204840:	00002617          	auipc	a2,0x2
ffffffffc0204844:	40860613          	addi	a2,a2,1032 # ffffffffc0206c48 <default_pmm_manager+0x148>
ffffffffc0204848:	1a500593          	li	a1,421
ffffffffc020484c:	00002517          	auipc	a0,0x2
ffffffffc0204850:	38c50513          	addi	a0,a0,908 # ffffffffc0206bd8 <default_pmm_manager+0xd8>
ffffffffc0204854:	983fb0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(initproc != NULL && initproc->pid == 1);
ffffffffc0204858:	00002697          	auipc	a3,0x2
ffffffffc020485c:	48868693          	addi	a3,a3,1160 # ffffffffc0206ce0 <default_pmm_manager+0x1e0>
ffffffffc0204860:	00001617          	auipc	a2,0x1
ffffffffc0204864:	12860613          	addi	a2,a2,296 # ffffffffc0205988 <commands+0x998>
ffffffffc0204868:	1cc00593          	li	a1,460
ffffffffc020486c:	00002517          	auipc	a0,0x2
ffffffffc0204870:	36c50513          	addi	a0,a0,876 # ffffffffc0206bd8 <default_pmm_manager+0xd8>
ffffffffc0204874:	963fb0ef          	jal	ra,ffffffffc02001d6 <__panic>
    assert(idleproc != NULL && idleproc->pid == 0);
ffffffffc0204878:	00002697          	auipc	a3,0x2
ffffffffc020487c:	44068693          	addi	a3,a3,1088 # ffffffffc0206cb8 <default_pmm_manager+0x1b8>
ffffffffc0204880:	00001617          	auipc	a2,0x1
ffffffffc0204884:	10860613          	addi	a2,a2,264 # ffffffffc0205988 <commands+0x998>
ffffffffc0204888:	1cb00593          	li	a1,459
ffffffffc020488c:	00002517          	auipc	a0,0x2
ffffffffc0204890:	34c50513          	addi	a0,a0,844 # ffffffffc0206bd8 <default_pmm_manager+0xd8>
ffffffffc0204894:	943fb0ef          	jal	ra,ffffffffc02001d6 <__panic>
        panic("create init_main failed.\n");
ffffffffc0204898:	00002617          	auipc	a2,0x2
ffffffffc020489c:	3f860613          	addi	a2,a2,1016 # ffffffffc0206c90 <default_pmm_manager+0x190>
ffffffffc02048a0:	1c500593          	li	a1,453
ffffffffc02048a4:	00002517          	auipc	a0,0x2
ffffffffc02048a8:	33450513          	addi	a0,a0,820 # ffffffffc0206bd8 <default_pmm_manager+0xd8>
ffffffffc02048ac:	92bfb0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc02048b0 <cpu_idle>:

// cpu_idle - at the end of kern_init, the first kernel thread idleproc will do below works
void
cpu_idle(void) {
ffffffffc02048b0:	1141                	addi	sp,sp,-16
ffffffffc02048b2:	e022                	sd	s0,0(sp)
ffffffffc02048b4:	e406                	sd	ra,8(sp)
ffffffffc02048b6:	00011417          	auipc	s0,0x11
ffffffffc02048ba:	bfa40413          	addi	s0,s0,-1030 # ffffffffc02154b0 <current>
    while (1) {
        if (current->need_resched) {
ffffffffc02048be:	6018                	ld	a4,0(s0)
ffffffffc02048c0:	4f1c                	lw	a5,24(a4)
ffffffffc02048c2:	2781                	sext.w	a5,a5
ffffffffc02048c4:	dff5                	beqz	a5,ffffffffc02048c0 <cpu_idle+0x10>
            schedule();
ffffffffc02048c6:	038000ef          	jal	ra,ffffffffc02048fe <schedule>
ffffffffc02048ca:	bfd5                	j	ffffffffc02048be <cpu_idle+0xe>

ffffffffc02048cc <wakeup_proc>:
#include <sched.h>
#include <assert.h>

void
wakeup_proc(struct proc_struct *proc) {
    assert(proc->state != PROC_ZOMBIE && proc->state != PROC_RUNNABLE);
ffffffffc02048cc:	411c                	lw	a5,0(a0)
ffffffffc02048ce:	4705                	li	a4,1
ffffffffc02048d0:	37f9                	addiw	a5,a5,-2
ffffffffc02048d2:	00f77563          	bleu	a5,a4,ffffffffc02048dc <wakeup_proc+0x10>
    proc->state = PROC_RUNNABLE;
ffffffffc02048d6:	4789                	li	a5,2
ffffffffc02048d8:	c11c                	sw	a5,0(a0)
ffffffffc02048da:	8082                	ret
wakeup_proc(struct proc_struct *proc) {
ffffffffc02048dc:	1141                	addi	sp,sp,-16
    assert(proc->state != PROC_ZOMBIE && proc->state != PROC_RUNNABLE);
ffffffffc02048de:	00002697          	auipc	a3,0x2
ffffffffc02048e2:	42a68693          	addi	a3,a3,1066 # ffffffffc0206d08 <default_pmm_manager+0x208>
ffffffffc02048e6:	00001617          	auipc	a2,0x1
ffffffffc02048ea:	0a260613          	addi	a2,a2,162 # ffffffffc0205988 <commands+0x998>
ffffffffc02048ee:	45a5                	li	a1,9
ffffffffc02048f0:	00002517          	auipc	a0,0x2
ffffffffc02048f4:	45850513          	addi	a0,a0,1112 # ffffffffc0206d48 <default_pmm_manager+0x248>
wakeup_proc(struct proc_struct *proc) {
ffffffffc02048f8:	e406                	sd	ra,8(sp)
    assert(proc->state != PROC_ZOMBIE && proc->state != PROC_RUNNABLE);
ffffffffc02048fa:	8ddfb0ef          	jal	ra,ffffffffc02001d6 <__panic>

ffffffffc02048fe <schedule>:
}

void
schedule(void) {
ffffffffc02048fe:	1141                	addi	sp,sp,-16
ffffffffc0204900:	e406                	sd	ra,8(sp)
ffffffffc0204902:	e022                	sd	s0,0(sp)
    if (read_csr(sstatus) & SSTATUS_SIE) {
ffffffffc0204904:	100027f3          	csrr	a5,sstatus
ffffffffc0204908:	8b89                	andi	a5,a5,2
ffffffffc020490a:	4401                	li	s0,0
ffffffffc020490c:	e3d1                	bnez	a5,ffffffffc0204990 <schedule+0x92>
    bool intr_flag;
    list_entry_t *le, *last;
    struct proc_struct *next = NULL;
    local_intr_save(intr_flag);
    {
        current->need_resched = 0;
ffffffffc020490e:	00011797          	auipc	a5,0x11
ffffffffc0204912:	ba278793          	addi	a5,a5,-1118 # ffffffffc02154b0 <current>
ffffffffc0204916:	0007b883          	ld	a7,0(a5)
        last = (current == idleproc) ? &proc_list : &(current->list_link);
ffffffffc020491a:	00011797          	auipc	a5,0x11
ffffffffc020491e:	b9e78793          	addi	a5,a5,-1122 # ffffffffc02154b8 <idleproc>
ffffffffc0204922:	6388                	ld	a0,0(a5)
        current->need_resched = 0;
ffffffffc0204924:	0008ac23          	sw	zero,24(a7) # 2018 <BASE_ADDRESS-0xffffffffc01fdfe8>
        last = (current == idleproc) ? &proc_list : &(current->list_link);
ffffffffc0204928:	04a88e63          	beq	a7,a0,ffffffffc0204984 <schedule+0x86>
ffffffffc020492c:	0c888693          	addi	a3,a7,200
ffffffffc0204930:	00011617          	auipc	a2,0x11
ffffffffc0204934:	cc060613          	addi	a2,a2,-832 # ffffffffc02155f0 <proc_list>
        le = last;
ffffffffc0204938:	87b6                	mv	a5,a3
    struct proc_struct *next = NULL;
ffffffffc020493a:	4581                	li	a1,0
        do {
            if ((le = list_next(le)) != &proc_list) {
                next = le2proc(le, list_link);
                if (next->state == PROC_RUNNABLE) {
ffffffffc020493c:	4809                	li	a6,2
    return listelm->next;
ffffffffc020493e:	679c                	ld	a5,8(a5)
            if ((le = list_next(le)) != &proc_list) {
ffffffffc0204940:	00c78863          	beq	a5,a2,ffffffffc0204950 <schedule+0x52>
                if (next->state == PROC_RUNNABLE) {
ffffffffc0204944:	f387a703          	lw	a4,-200(a5)
                next = le2proc(le, list_link);
ffffffffc0204948:	f3878593          	addi	a1,a5,-200
                if (next->state == PROC_RUNNABLE) {
ffffffffc020494c:	01070463          	beq	a4,a6,ffffffffc0204954 <schedule+0x56>
                    break;
                }
            }
        } while (le != last);
ffffffffc0204950:	fef697e3          	bne	a3,a5,ffffffffc020493e <schedule+0x40>
        if (next == NULL || next->state != PROC_RUNNABLE) {
ffffffffc0204954:	c589                	beqz	a1,ffffffffc020495e <schedule+0x60>
ffffffffc0204956:	4198                	lw	a4,0(a1)
ffffffffc0204958:	4789                	li	a5,2
ffffffffc020495a:	00f70e63          	beq	a4,a5,ffffffffc0204976 <schedule+0x78>
            next = idleproc;
        }
        next->runs ++;
ffffffffc020495e:	451c                	lw	a5,8(a0)
ffffffffc0204960:	2785                	addiw	a5,a5,1
ffffffffc0204962:	c51c                	sw	a5,8(a0)
        if (next != current) {
ffffffffc0204964:	00a88463          	beq	a7,a0,ffffffffc020496c <schedule+0x6e>
            proc_run(next);
ffffffffc0204968:	9efff0ef          	jal	ra,ffffffffc0204356 <proc_run>
    if (flag) {
ffffffffc020496c:	e419                	bnez	s0,ffffffffc020497a <schedule+0x7c>
        }
    }
    local_intr_restore(intr_flag);
}
ffffffffc020496e:	60a2                	ld	ra,8(sp)
ffffffffc0204970:	6402                	ld	s0,0(sp)
ffffffffc0204972:	0141                	addi	sp,sp,16
ffffffffc0204974:	8082                	ret
        if (next == NULL || next->state != PROC_RUNNABLE) {
ffffffffc0204976:	852e                	mv	a0,a1
ffffffffc0204978:	b7dd                	j	ffffffffc020495e <schedule+0x60>
}
ffffffffc020497a:	6402                	ld	s0,0(sp)
ffffffffc020497c:	60a2                	ld	ra,8(sp)
ffffffffc020497e:	0141                	addi	sp,sp,16
        intr_enable();
ffffffffc0204980:	c55fb06f          	j	ffffffffc02005d4 <intr_enable>
        last = (current == idleproc) ? &proc_list : &(current->list_link);
ffffffffc0204984:	00011617          	auipc	a2,0x11
ffffffffc0204988:	c6c60613          	addi	a2,a2,-916 # ffffffffc02155f0 <proc_list>
ffffffffc020498c:	86b2                	mv	a3,a2
ffffffffc020498e:	b76d                	j	ffffffffc0204938 <schedule+0x3a>
        intr_disable();
ffffffffc0204990:	c4bfb0ef          	jal	ra,ffffffffc02005da <intr_disable>
        return 1;
ffffffffc0204994:	4405                	li	s0,1
ffffffffc0204996:	bfa5                	j	ffffffffc020490e <schedule+0x10>

ffffffffc0204998 <strlen>:
 * The strlen() function returns the length of string @s.
 * */
size_t
strlen(const char *s) {
    size_t cnt = 0;
    while (*s ++ != '\0') {
ffffffffc0204998:	00054783          	lbu	a5,0(a0)
ffffffffc020499c:	cb91                	beqz	a5,ffffffffc02049b0 <strlen+0x18>
    size_t cnt = 0;
ffffffffc020499e:	4781                	li	a5,0
        cnt ++;
ffffffffc02049a0:	0785                	addi	a5,a5,1
    while (*s ++ != '\0') {
ffffffffc02049a2:	00f50733          	add	a4,a0,a5
ffffffffc02049a6:	00074703          	lbu	a4,0(a4)
ffffffffc02049aa:	fb7d                	bnez	a4,ffffffffc02049a0 <strlen+0x8>
    }
    return cnt;
}
ffffffffc02049ac:	853e                	mv	a0,a5
ffffffffc02049ae:	8082                	ret
    size_t cnt = 0;
ffffffffc02049b0:	4781                	li	a5,0
}
ffffffffc02049b2:	853e                	mv	a0,a5
ffffffffc02049b4:	8082                	ret

ffffffffc02049b6 <strnlen>:
 * pointed by @s.
 * */
size_t
strnlen(const char *s, size_t len) {
    size_t cnt = 0;
    while (cnt < len && *s ++ != '\0') {
ffffffffc02049b6:	c185                	beqz	a1,ffffffffc02049d6 <strnlen+0x20>
ffffffffc02049b8:	00054783          	lbu	a5,0(a0)
ffffffffc02049bc:	cf89                	beqz	a5,ffffffffc02049d6 <strnlen+0x20>
    size_t cnt = 0;
ffffffffc02049be:	4781                	li	a5,0
ffffffffc02049c0:	a021                	j	ffffffffc02049c8 <strnlen+0x12>
    while (cnt < len && *s ++ != '\0') {
ffffffffc02049c2:	00074703          	lbu	a4,0(a4)
ffffffffc02049c6:	c711                	beqz	a4,ffffffffc02049d2 <strnlen+0x1c>
        cnt ++;
ffffffffc02049c8:	0785                	addi	a5,a5,1
    while (cnt < len && *s ++ != '\0') {
ffffffffc02049ca:	00f50733          	add	a4,a0,a5
ffffffffc02049ce:	fef59ae3          	bne	a1,a5,ffffffffc02049c2 <strnlen+0xc>
    }
    return cnt;
}
ffffffffc02049d2:	853e                	mv	a0,a5
ffffffffc02049d4:	8082                	ret
    size_t cnt = 0;
ffffffffc02049d6:	4781                	li	a5,0
}
ffffffffc02049d8:	853e                	mv	a0,a5
ffffffffc02049da:	8082                	ret

ffffffffc02049dc <strcpy>:
char *
strcpy(char *dst, const char *src) {
#ifdef __HAVE_ARCH_STRCPY
    return __strcpy(dst, src);
#else
    char *p = dst;
ffffffffc02049dc:	87aa                	mv	a5,a0
    while ((*p ++ = *src ++) != '\0')
ffffffffc02049de:	0585                	addi	a1,a1,1
ffffffffc02049e0:	fff5c703          	lbu	a4,-1(a1)
ffffffffc02049e4:	0785                	addi	a5,a5,1
ffffffffc02049e6:	fee78fa3          	sb	a4,-1(a5)
ffffffffc02049ea:	fb75                	bnez	a4,ffffffffc02049de <strcpy+0x2>
        /* nothing */;
    return dst;
#endif /* __HAVE_ARCH_STRCPY */
}
ffffffffc02049ec:	8082                	ret

ffffffffc02049ee <strcmp>:
int
strcmp(const char *s1, const char *s2) {
#ifdef __HAVE_ARCH_STRCMP
    return __strcmp(s1, s2);
#else
    while (*s1 != '\0' && *s1 == *s2) {
ffffffffc02049ee:	00054783          	lbu	a5,0(a0)
ffffffffc02049f2:	0005c703          	lbu	a4,0(a1)
ffffffffc02049f6:	cb91                	beqz	a5,ffffffffc0204a0a <strcmp+0x1c>
ffffffffc02049f8:	00e79c63          	bne	a5,a4,ffffffffc0204a10 <strcmp+0x22>
        s1 ++, s2 ++;
ffffffffc02049fc:	0505                	addi	a0,a0,1
    while (*s1 != '\0' && *s1 == *s2) {
ffffffffc02049fe:	00054783          	lbu	a5,0(a0)
        s1 ++, s2 ++;
ffffffffc0204a02:	0585                	addi	a1,a1,1
ffffffffc0204a04:	0005c703          	lbu	a4,0(a1)
    while (*s1 != '\0' && *s1 == *s2) {
ffffffffc0204a08:	fbe5                	bnez	a5,ffffffffc02049f8 <strcmp+0xa>
    }
    return (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0204a0a:	4501                	li	a0,0
#endif /* __HAVE_ARCH_STRCMP */
}
ffffffffc0204a0c:	9d19                	subw	a0,a0,a4
ffffffffc0204a0e:	8082                	ret
ffffffffc0204a10:	0007851b          	sext.w	a0,a5
ffffffffc0204a14:	9d19                	subw	a0,a0,a4
ffffffffc0204a16:	8082                	ret

ffffffffc0204a18 <strchr>:
 * The strchr() function returns a pointer to the first occurrence of
 * character in @s. If the value is not found, the function returns 'NULL'.
 * */
char *
strchr(const char *s, char c) {
    while (*s != '\0') {
ffffffffc0204a18:	00054783          	lbu	a5,0(a0)
ffffffffc0204a1c:	cb91                	beqz	a5,ffffffffc0204a30 <strchr+0x18>
        if (*s == c) {
ffffffffc0204a1e:	00b79563          	bne	a5,a1,ffffffffc0204a28 <strchr+0x10>
ffffffffc0204a22:	a809                	j	ffffffffc0204a34 <strchr+0x1c>
ffffffffc0204a24:	00b78763          	beq	a5,a1,ffffffffc0204a32 <strchr+0x1a>
            return (char *)s;
        }
        s ++;
ffffffffc0204a28:	0505                	addi	a0,a0,1
    while (*s != '\0') {
ffffffffc0204a2a:	00054783          	lbu	a5,0(a0)
ffffffffc0204a2e:	fbfd                	bnez	a5,ffffffffc0204a24 <strchr+0xc>
    }
    return NULL;
ffffffffc0204a30:	4501                	li	a0,0
}
ffffffffc0204a32:	8082                	ret
ffffffffc0204a34:	8082                	ret

ffffffffc0204a36 <memset>:
memset(void *s, char c, size_t n) {
#ifdef __HAVE_ARCH_MEMSET
    return __memset(s, c, n);
#else
    char *p = s;
    while (n -- > 0) {
ffffffffc0204a36:	ca01                	beqz	a2,ffffffffc0204a46 <memset+0x10>
ffffffffc0204a38:	962a                	add	a2,a2,a0
    char *p = s;
ffffffffc0204a3a:	87aa                	mv	a5,a0
        *p ++ = c;
ffffffffc0204a3c:	0785                	addi	a5,a5,1
ffffffffc0204a3e:	feb78fa3          	sb	a1,-1(a5)
    while (n -- > 0) {
ffffffffc0204a42:	fec79de3          	bne	a5,a2,ffffffffc0204a3c <memset+0x6>
    }
    return s;
#endif /* __HAVE_ARCH_MEMSET */
}
ffffffffc0204a46:	8082                	ret

ffffffffc0204a48 <memcpy>:
#ifdef __HAVE_ARCH_MEMCPY
    return __memcpy(dst, src, n);
#else
    const char *s = src;
    char *d = dst;
    while (n -- > 0) {
ffffffffc0204a48:	ca19                	beqz	a2,ffffffffc0204a5e <memcpy+0x16>
ffffffffc0204a4a:	962e                	add	a2,a2,a1
    char *d = dst;
ffffffffc0204a4c:	87aa                	mv	a5,a0
        *d ++ = *s ++;
ffffffffc0204a4e:	0585                	addi	a1,a1,1
ffffffffc0204a50:	fff5c703          	lbu	a4,-1(a1)
ffffffffc0204a54:	0785                	addi	a5,a5,1
ffffffffc0204a56:	fee78fa3          	sb	a4,-1(a5)
    while (n -- > 0) {
ffffffffc0204a5a:	fec59ae3          	bne	a1,a2,ffffffffc0204a4e <memcpy+0x6>
    }
    return dst;
#endif /* __HAVE_ARCH_MEMCPY */
}
ffffffffc0204a5e:	8082                	ret

ffffffffc0204a60 <memcmp>:
 * */
int
memcmp(const void *v1, const void *v2, size_t n) {
    const char *s1 = (const char *)v1;
    const char *s2 = (const char *)v2;
    while (n -- > 0) {
ffffffffc0204a60:	c21d                	beqz	a2,ffffffffc0204a86 <memcmp+0x26>
        if (*s1 != *s2) {
ffffffffc0204a62:	00054783          	lbu	a5,0(a0)
ffffffffc0204a66:	0005c703          	lbu	a4,0(a1)
ffffffffc0204a6a:	962a                	add	a2,a2,a0
ffffffffc0204a6c:	00f70963          	beq	a4,a5,ffffffffc0204a7e <memcmp+0x1e>
ffffffffc0204a70:	a829                	j	ffffffffc0204a8a <memcmp+0x2a>
ffffffffc0204a72:	00054783          	lbu	a5,0(a0)
ffffffffc0204a76:	0005c703          	lbu	a4,0(a1)
ffffffffc0204a7a:	00e79863          	bne	a5,a4,ffffffffc0204a8a <memcmp+0x2a>
            return (int)((unsigned char)*s1 - (unsigned char)*s2);
        }
        s1 ++, s2 ++;
ffffffffc0204a7e:	0505                	addi	a0,a0,1
ffffffffc0204a80:	0585                	addi	a1,a1,1
    while (n -- > 0) {
ffffffffc0204a82:	fea618e3          	bne	a2,a0,ffffffffc0204a72 <memcmp+0x12>
    }
    return 0;
ffffffffc0204a86:	4501                	li	a0,0
}
ffffffffc0204a88:	8082                	ret
            return (int)((unsigned char)*s1 - (unsigned char)*s2);
ffffffffc0204a8a:	40e7853b          	subw	a0,a5,a4
ffffffffc0204a8e:	8082                	ret

ffffffffc0204a90 <printnum>:
 * */
static void
printnum(void (*putch)(int, void*), void *putdat,
        unsigned long long num, unsigned base, int width, int padc) {
    unsigned long long result = num;
    unsigned mod = do_div(result, base);
ffffffffc0204a90:	02069813          	slli	a6,a3,0x20
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc0204a94:	7179                	addi	sp,sp,-48
    unsigned mod = do_div(result, base);
ffffffffc0204a96:	02085813          	srli	a6,a6,0x20
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc0204a9a:	e052                	sd	s4,0(sp)
    unsigned mod = do_div(result, base);
ffffffffc0204a9c:	03067a33          	remu	s4,a2,a6
        unsigned long long num, unsigned base, int width, int padc) {
ffffffffc0204aa0:	f022                	sd	s0,32(sp)
ffffffffc0204aa2:	ec26                	sd	s1,24(sp)
ffffffffc0204aa4:	e84a                	sd	s2,16(sp)
ffffffffc0204aa6:	f406                	sd	ra,40(sp)
ffffffffc0204aa8:	e44e                	sd	s3,8(sp)
ffffffffc0204aaa:	84aa                	mv	s1,a0
ffffffffc0204aac:	892e                	mv	s2,a1
ffffffffc0204aae:	fff7041b          	addiw	s0,a4,-1
    unsigned mod = do_div(result, base);
ffffffffc0204ab2:	2a01                	sext.w	s4,s4

    // first recursively print all preceding (more significant) digits
    if (num >= base) {
ffffffffc0204ab4:	03067e63          	bleu	a6,a2,ffffffffc0204af0 <printnum+0x60>
ffffffffc0204ab8:	89be                	mv	s3,a5
        printnum(putch, putdat, result, base, width - 1, padc);
    } else {
        // print any needed pad characters before first digit
        while (-- width > 0)
ffffffffc0204aba:	00805763          	blez	s0,ffffffffc0204ac8 <printnum+0x38>
ffffffffc0204abe:	347d                	addiw	s0,s0,-1
            putch(padc, putdat);
ffffffffc0204ac0:	85ca                	mv	a1,s2
ffffffffc0204ac2:	854e                	mv	a0,s3
ffffffffc0204ac4:	9482                	jalr	s1
        while (-- width > 0)
ffffffffc0204ac6:	fc65                	bnez	s0,ffffffffc0204abe <printnum+0x2e>
    }
    // then print this (the least significant) digit
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0204ac8:	1a02                	slli	s4,s4,0x20
ffffffffc0204aca:	020a5a13          	srli	s4,s4,0x20
ffffffffc0204ace:	00002797          	auipc	a5,0x2
ffffffffc0204ad2:	42278793          	addi	a5,a5,1058 # ffffffffc0206ef0 <error_string+0x38>
ffffffffc0204ad6:	9a3e                	add	s4,s4,a5
}
ffffffffc0204ad8:	7402                	ld	s0,32(sp)
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0204ada:	000a4503          	lbu	a0,0(s4)
}
ffffffffc0204ade:	70a2                	ld	ra,40(sp)
ffffffffc0204ae0:	69a2                	ld	s3,8(sp)
ffffffffc0204ae2:	6a02                	ld	s4,0(sp)
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0204ae4:	85ca                	mv	a1,s2
ffffffffc0204ae6:	8326                	mv	t1,s1
}
ffffffffc0204ae8:	6942                	ld	s2,16(sp)
ffffffffc0204aea:	64e2                	ld	s1,24(sp)
ffffffffc0204aec:	6145                	addi	sp,sp,48
    putch("0123456789abcdef"[mod], putdat);
ffffffffc0204aee:	8302                	jr	t1
        printnum(putch, putdat, result, base, width - 1, padc);
ffffffffc0204af0:	03065633          	divu	a2,a2,a6
ffffffffc0204af4:	8722                	mv	a4,s0
ffffffffc0204af6:	f9bff0ef          	jal	ra,ffffffffc0204a90 <printnum>
ffffffffc0204afa:	b7f9                	j	ffffffffc0204ac8 <printnum+0x38>

ffffffffc0204afc <vprintfmt>:
 *
 * Call this function if you are already dealing with a va_list.
 * Or you probably want printfmt() instead.
 * */
void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) {
ffffffffc0204afc:	7119                	addi	sp,sp,-128
ffffffffc0204afe:	f4a6                	sd	s1,104(sp)
ffffffffc0204b00:	f0ca                	sd	s2,96(sp)
ffffffffc0204b02:	e8d2                	sd	s4,80(sp)
ffffffffc0204b04:	e4d6                	sd	s5,72(sp)
ffffffffc0204b06:	e0da                	sd	s6,64(sp)
ffffffffc0204b08:	fc5e                	sd	s7,56(sp)
ffffffffc0204b0a:	f862                	sd	s8,48(sp)
ffffffffc0204b0c:	f06a                	sd	s10,32(sp)
ffffffffc0204b0e:	fc86                	sd	ra,120(sp)
ffffffffc0204b10:	f8a2                	sd	s0,112(sp)
ffffffffc0204b12:	ecce                	sd	s3,88(sp)
ffffffffc0204b14:	f466                	sd	s9,40(sp)
ffffffffc0204b16:	ec6e                	sd	s11,24(sp)
ffffffffc0204b18:	892a                	mv	s2,a0
ffffffffc0204b1a:	84ae                	mv	s1,a1
ffffffffc0204b1c:	8d32                	mv	s10,a2
ffffffffc0204b1e:	8ab6                	mv	s5,a3
            putch(ch, putdat);
        }

        // Process a %-escape sequence
        char padc = ' ';
        width = precision = -1;
ffffffffc0204b20:	5b7d                	li	s6,-1
        lflag = altflag = 0;

    reswitch:
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204b22:	00002a17          	auipc	s4,0x2
ffffffffc0204b26:	23ea0a13          	addi	s4,s4,574 # ffffffffc0206d60 <default_pmm_manager+0x260>
                for (width -= strnlen(p, precision); width > 0; width --) {
                    putch(padc, putdat);
                }
            }
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0204b2a:	05e00b93          	li	s7,94
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc0204b2e:	00002c17          	auipc	s8,0x2
ffffffffc0204b32:	38ac0c13          	addi	s8,s8,906 # ffffffffc0206eb8 <error_string>
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc0204b36:	000d4503          	lbu	a0,0(s10) # 1000 <BASE_ADDRESS-0xffffffffc01ff000>
ffffffffc0204b3a:	02500793          	li	a5,37
ffffffffc0204b3e:	001d0413          	addi	s0,s10,1
ffffffffc0204b42:	00f50e63          	beq	a0,a5,ffffffffc0204b5e <vprintfmt+0x62>
            if (ch == '\0') {
ffffffffc0204b46:	c521                	beqz	a0,ffffffffc0204b8e <vprintfmt+0x92>
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc0204b48:	02500993          	li	s3,37
ffffffffc0204b4c:	a011                	j	ffffffffc0204b50 <vprintfmt+0x54>
            if (ch == '\0') {
ffffffffc0204b4e:	c121                	beqz	a0,ffffffffc0204b8e <vprintfmt+0x92>
            putch(ch, putdat);
ffffffffc0204b50:	85a6                	mv	a1,s1
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc0204b52:	0405                	addi	s0,s0,1
            putch(ch, putdat);
ffffffffc0204b54:	9902                	jalr	s2
        while ((ch = *(unsigned char *)fmt ++) != '%') {
ffffffffc0204b56:	fff44503          	lbu	a0,-1(s0)
ffffffffc0204b5a:	ff351ae3          	bne	a0,s3,ffffffffc0204b4e <vprintfmt+0x52>
ffffffffc0204b5e:	00044603          	lbu	a2,0(s0)
        char padc = ' ';
ffffffffc0204b62:	02000793          	li	a5,32
        lflag = altflag = 0;
ffffffffc0204b66:	4981                	li	s3,0
ffffffffc0204b68:	4801                	li	a6,0
        width = precision = -1;
ffffffffc0204b6a:	5cfd                	li	s9,-1
ffffffffc0204b6c:	5dfd                	li	s11,-1
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204b6e:	05500593          	li	a1,85
                if (ch < '0' || ch > '9') {
ffffffffc0204b72:	4525                	li	a0,9
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204b74:	fdd6069b          	addiw	a3,a2,-35
ffffffffc0204b78:	0ff6f693          	andi	a3,a3,255
ffffffffc0204b7c:	00140d13          	addi	s10,s0,1
ffffffffc0204b80:	20d5e563          	bltu	a1,a3,ffffffffc0204d8a <vprintfmt+0x28e>
ffffffffc0204b84:	068a                	slli	a3,a3,0x2
ffffffffc0204b86:	96d2                	add	a3,a3,s4
ffffffffc0204b88:	4294                	lw	a3,0(a3)
ffffffffc0204b8a:	96d2                	add	a3,a3,s4
ffffffffc0204b8c:	8682                	jr	a3
            for (fmt --; fmt[-1] != '%'; fmt --)
                /* do nothing */;
            break;
        }
    }
}
ffffffffc0204b8e:	70e6                	ld	ra,120(sp)
ffffffffc0204b90:	7446                	ld	s0,112(sp)
ffffffffc0204b92:	74a6                	ld	s1,104(sp)
ffffffffc0204b94:	7906                	ld	s2,96(sp)
ffffffffc0204b96:	69e6                	ld	s3,88(sp)
ffffffffc0204b98:	6a46                	ld	s4,80(sp)
ffffffffc0204b9a:	6aa6                	ld	s5,72(sp)
ffffffffc0204b9c:	6b06                	ld	s6,64(sp)
ffffffffc0204b9e:	7be2                	ld	s7,56(sp)
ffffffffc0204ba0:	7c42                	ld	s8,48(sp)
ffffffffc0204ba2:	7ca2                	ld	s9,40(sp)
ffffffffc0204ba4:	7d02                	ld	s10,32(sp)
ffffffffc0204ba6:	6de2                	ld	s11,24(sp)
ffffffffc0204ba8:	6109                	addi	sp,sp,128
ffffffffc0204baa:	8082                	ret
    if (lflag >= 2) {
ffffffffc0204bac:	4705                	li	a4,1
ffffffffc0204bae:	008a8593          	addi	a1,s5,8
ffffffffc0204bb2:	01074463          	blt	a4,a6,ffffffffc0204bba <vprintfmt+0xbe>
    else if (lflag) {
ffffffffc0204bb6:	26080363          	beqz	a6,ffffffffc0204e1c <vprintfmt+0x320>
        return va_arg(*ap, unsigned long);
ffffffffc0204bba:	000ab603          	ld	a2,0(s5)
ffffffffc0204bbe:	46c1                	li	a3,16
ffffffffc0204bc0:	8aae                	mv	s5,a1
ffffffffc0204bc2:	a06d                	j	ffffffffc0204c6c <vprintfmt+0x170>
            goto reswitch;
ffffffffc0204bc4:	00144603          	lbu	a2,1(s0)
            altflag = 1;
ffffffffc0204bc8:	4985                	li	s3,1
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204bca:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0204bcc:	b765                	j	ffffffffc0204b74 <vprintfmt+0x78>
            putch(va_arg(ap, int), putdat);
ffffffffc0204bce:	000aa503          	lw	a0,0(s5)
ffffffffc0204bd2:	85a6                	mv	a1,s1
ffffffffc0204bd4:	0aa1                	addi	s5,s5,8
ffffffffc0204bd6:	9902                	jalr	s2
            break;
ffffffffc0204bd8:	bfb9                	j	ffffffffc0204b36 <vprintfmt+0x3a>
    if (lflag >= 2) {
ffffffffc0204bda:	4705                	li	a4,1
ffffffffc0204bdc:	008a8993          	addi	s3,s5,8
ffffffffc0204be0:	01074463          	blt	a4,a6,ffffffffc0204be8 <vprintfmt+0xec>
    else if (lflag) {
ffffffffc0204be4:	22080463          	beqz	a6,ffffffffc0204e0c <vprintfmt+0x310>
        return va_arg(*ap, long);
ffffffffc0204be8:	000ab403          	ld	s0,0(s5)
            if ((long long)num < 0) {
ffffffffc0204bec:	24044463          	bltz	s0,ffffffffc0204e34 <vprintfmt+0x338>
            num = getint(&ap, lflag);
ffffffffc0204bf0:	8622                	mv	a2,s0
ffffffffc0204bf2:	8ace                	mv	s5,s3
ffffffffc0204bf4:	46a9                	li	a3,10
ffffffffc0204bf6:	a89d                	j	ffffffffc0204c6c <vprintfmt+0x170>
            err = va_arg(ap, int);
ffffffffc0204bf8:	000aa783          	lw	a5,0(s5)
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc0204bfc:	4719                	li	a4,6
            err = va_arg(ap, int);
ffffffffc0204bfe:	0aa1                	addi	s5,s5,8
            if (err < 0) {
ffffffffc0204c00:	41f7d69b          	sraiw	a3,a5,0x1f
ffffffffc0204c04:	8fb5                	xor	a5,a5,a3
ffffffffc0204c06:	40d786bb          	subw	a3,a5,a3
            if (err > MAXERROR || (p = error_string[err]) == NULL) {
ffffffffc0204c0a:	1ad74363          	blt	a4,a3,ffffffffc0204db0 <vprintfmt+0x2b4>
ffffffffc0204c0e:	00369793          	slli	a5,a3,0x3
ffffffffc0204c12:	97e2                	add	a5,a5,s8
ffffffffc0204c14:	639c                	ld	a5,0(a5)
ffffffffc0204c16:	18078d63          	beqz	a5,ffffffffc0204db0 <vprintfmt+0x2b4>
                printfmt(putch, putdat, "%s", p);
ffffffffc0204c1a:	86be                	mv	a3,a5
ffffffffc0204c1c:	00000617          	auipc	a2,0x0
ffffffffc0204c20:	2ac60613          	addi	a2,a2,684 # ffffffffc0204ec8 <etext+0x28>
ffffffffc0204c24:	85a6                	mv	a1,s1
ffffffffc0204c26:	854a                	mv	a0,s2
ffffffffc0204c28:	240000ef          	jal	ra,ffffffffc0204e68 <printfmt>
ffffffffc0204c2c:	b729                	j	ffffffffc0204b36 <vprintfmt+0x3a>
            lflag ++;
ffffffffc0204c2e:	00144603          	lbu	a2,1(s0)
ffffffffc0204c32:	2805                	addiw	a6,a6,1
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204c34:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0204c36:	bf3d                	j	ffffffffc0204b74 <vprintfmt+0x78>
    if (lflag >= 2) {
ffffffffc0204c38:	4705                	li	a4,1
ffffffffc0204c3a:	008a8593          	addi	a1,s5,8
ffffffffc0204c3e:	01074463          	blt	a4,a6,ffffffffc0204c46 <vprintfmt+0x14a>
    else if (lflag) {
ffffffffc0204c42:	1e080263          	beqz	a6,ffffffffc0204e26 <vprintfmt+0x32a>
        return va_arg(*ap, unsigned long);
ffffffffc0204c46:	000ab603          	ld	a2,0(s5)
ffffffffc0204c4a:	46a1                	li	a3,8
ffffffffc0204c4c:	8aae                	mv	s5,a1
ffffffffc0204c4e:	a839                	j	ffffffffc0204c6c <vprintfmt+0x170>
            putch('0', putdat);
ffffffffc0204c50:	03000513          	li	a0,48
ffffffffc0204c54:	85a6                	mv	a1,s1
ffffffffc0204c56:	e03e                	sd	a5,0(sp)
ffffffffc0204c58:	9902                	jalr	s2
            putch('x', putdat);
ffffffffc0204c5a:	85a6                	mv	a1,s1
ffffffffc0204c5c:	07800513          	li	a0,120
ffffffffc0204c60:	9902                	jalr	s2
            num = (unsigned long long)(uintptr_t)va_arg(ap, void *);
ffffffffc0204c62:	0aa1                	addi	s5,s5,8
ffffffffc0204c64:	ff8ab603          	ld	a2,-8(s5)
            goto number;
ffffffffc0204c68:	6782                	ld	a5,0(sp)
ffffffffc0204c6a:	46c1                	li	a3,16
            printnum(putch, putdat, num, base, width, padc);
ffffffffc0204c6c:	876e                	mv	a4,s11
ffffffffc0204c6e:	85a6                	mv	a1,s1
ffffffffc0204c70:	854a                	mv	a0,s2
ffffffffc0204c72:	e1fff0ef          	jal	ra,ffffffffc0204a90 <printnum>
            break;
ffffffffc0204c76:	b5c1                	j	ffffffffc0204b36 <vprintfmt+0x3a>
            if ((p = va_arg(ap, char *)) == NULL) {
ffffffffc0204c78:	000ab603          	ld	a2,0(s5)
ffffffffc0204c7c:	0aa1                	addi	s5,s5,8
ffffffffc0204c7e:	1c060663          	beqz	a2,ffffffffc0204e4a <vprintfmt+0x34e>
            if (width > 0 && padc != '-') {
ffffffffc0204c82:	00160413          	addi	s0,a2,1
ffffffffc0204c86:	17b05c63          	blez	s11,ffffffffc0204dfe <vprintfmt+0x302>
ffffffffc0204c8a:	02d00593          	li	a1,45
ffffffffc0204c8e:	14b79263          	bne	a5,a1,ffffffffc0204dd2 <vprintfmt+0x2d6>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0204c92:	00064783          	lbu	a5,0(a2)
ffffffffc0204c96:	0007851b          	sext.w	a0,a5
ffffffffc0204c9a:	c905                	beqz	a0,ffffffffc0204cca <vprintfmt+0x1ce>
ffffffffc0204c9c:	000cc563          	bltz	s9,ffffffffc0204ca6 <vprintfmt+0x1aa>
ffffffffc0204ca0:	3cfd                	addiw	s9,s9,-1
ffffffffc0204ca2:	036c8263          	beq	s9,s6,ffffffffc0204cc6 <vprintfmt+0x1ca>
                    putch('?', putdat);
ffffffffc0204ca6:	85a6                	mv	a1,s1
                if (altflag && (ch < ' ' || ch > '~')) {
ffffffffc0204ca8:	18098463          	beqz	s3,ffffffffc0204e30 <vprintfmt+0x334>
ffffffffc0204cac:	3781                	addiw	a5,a5,-32
ffffffffc0204cae:	18fbf163          	bleu	a5,s7,ffffffffc0204e30 <vprintfmt+0x334>
                    putch('?', putdat);
ffffffffc0204cb2:	03f00513          	li	a0,63
ffffffffc0204cb6:	9902                	jalr	s2
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0204cb8:	0405                	addi	s0,s0,1
ffffffffc0204cba:	fff44783          	lbu	a5,-1(s0)
ffffffffc0204cbe:	3dfd                	addiw	s11,s11,-1
ffffffffc0204cc0:	0007851b          	sext.w	a0,a5
ffffffffc0204cc4:	fd61                	bnez	a0,ffffffffc0204c9c <vprintfmt+0x1a0>
            for (; width > 0; width --) {
ffffffffc0204cc6:	e7b058e3          	blez	s11,ffffffffc0204b36 <vprintfmt+0x3a>
ffffffffc0204cca:	3dfd                	addiw	s11,s11,-1
                putch(' ', putdat);
ffffffffc0204ccc:	85a6                	mv	a1,s1
ffffffffc0204cce:	02000513          	li	a0,32
ffffffffc0204cd2:	9902                	jalr	s2
            for (; width > 0; width --) {
ffffffffc0204cd4:	e60d81e3          	beqz	s11,ffffffffc0204b36 <vprintfmt+0x3a>
ffffffffc0204cd8:	3dfd                	addiw	s11,s11,-1
                putch(' ', putdat);
ffffffffc0204cda:	85a6                	mv	a1,s1
ffffffffc0204cdc:	02000513          	li	a0,32
ffffffffc0204ce0:	9902                	jalr	s2
            for (; width > 0; width --) {
ffffffffc0204ce2:	fe0d94e3          	bnez	s11,ffffffffc0204cca <vprintfmt+0x1ce>
ffffffffc0204ce6:	bd81                	j	ffffffffc0204b36 <vprintfmt+0x3a>
    if (lflag >= 2) {
ffffffffc0204ce8:	4705                	li	a4,1
ffffffffc0204cea:	008a8593          	addi	a1,s5,8
ffffffffc0204cee:	01074463          	blt	a4,a6,ffffffffc0204cf6 <vprintfmt+0x1fa>
    else if (lflag) {
ffffffffc0204cf2:	12080063          	beqz	a6,ffffffffc0204e12 <vprintfmt+0x316>
        return va_arg(*ap, unsigned long);
ffffffffc0204cf6:	000ab603          	ld	a2,0(s5)
ffffffffc0204cfa:	46a9                	li	a3,10
ffffffffc0204cfc:	8aae                	mv	s5,a1
ffffffffc0204cfe:	b7bd                	j	ffffffffc0204c6c <vprintfmt+0x170>
ffffffffc0204d00:	00144603          	lbu	a2,1(s0)
            padc = '-';
ffffffffc0204d04:	02d00793          	li	a5,45
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204d08:	846a                	mv	s0,s10
ffffffffc0204d0a:	b5ad                	j	ffffffffc0204b74 <vprintfmt+0x78>
            putch(ch, putdat);
ffffffffc0204d0c:	85a6                	mv	a1,s1
ffffffffc0204d0e:	02500513          	li	a0,37
ffffffffc0204d12:	9902                	jalr	s2
            break;
ffffffffc0204d14:	b50d                	j	ffffffffc0204b36 <vprintfmt+0x3a>
            precision = va_arg(ap, int);
ffffffffc0204d16:	000aac83          	lw	s9,0(s5)
            goto process_precision;
ffffffffc0204d1a:	00144603          	lbu	a2,1(s0)
            precision = va_arg(ap, int);
ffffffffc0204d1e:	0aa1                	addi	s5,s5,8
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204d20:	846a                	mv	s0,s10
            if (width < 0)
ffffffffc0204d22:	e40dd9e3          	bgez	s11,ffffffffc0204b74 <vprintfmt+0x78>
                width = precision, precision = -1;
ffffffffc0204d26:	8de6                	mv	s11,s9
ffffffffc0204d28:	5cfd                	li	s9,-1
ffffffffc0204d2a:	b5a9                	j	ffffffffc0204b74 <vprintfmt+0x78>
            goto reswitch;
ffffffffc0204d2c:	00144603          	lbu	a2,1(s0)
            padc = '0';
ffffffffc0204d30:	03000793          	li	a5,48
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204d34:	846a                	mv	s0,s10
            goto reswitch;
ffffffffc0204d36:	bd3d                	j	ffffffffc0204b74 <vprintfmt+0x78>
                precision = precision * 10 + ch - '0';
ffffffffc0204d38:	fd060c9b          	addiw	s9,a2,-48
                ch = *fmt;
ffffffffc0204d3c:	00144603          	lbu	a2,1(s0)
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204d40:	846a                	mv	s0,s10
                if (ch < '0' || ch > '9') {
ffffffffc0204d42:	fd06069b          	addiw	a3,a2,-48
                ch = *fmt;
ffffffffc0204d46:	0006089b          	sext.w	a7,a2
                if (ch < '0' || ch > '9') {
ffffffffc0204d4a:	fcd56ce3          	bltu	a0,a3,ffffffffc0204d22 <vprintfmt+0x226>
            for (precision = 0; ; ++ fmt) {
ffffffffc0204d4e:	0405                	addi	s0,s0,1
                precision = precision * 10 + ch - '0';
ffffffffc0204d50:	002c969b          	slliw	a3,s9,0x2
                ch = *fmt;
ffffffffc0204d54:	00044603          	lbu	a2,0(s0)
                precision = precision * 10 + ch - '0';
ffffffffc0204d58:	0196873b          	addw	a4,a3,s9
ffffffffc0204d5c:	0017171b          	slliw	a4,a4,0x1
ffffffffc0204d60:	0117073b          	addw	a4,a4,a7
                if (ch < '0' || ch > '9') {
ffffffffc0204d64:	fd06069b          	addiw	a3,a2,-48
                precision = precision * 10 + ch - '0';
ffffffffc0204d68:	fd070c9b          	addiw	s9,a4,-48
                ch = *fmt;
ffffffffc0204d6c:	0006089b          	sext.w	a7,a2
                if (ch < '0' || ch > '9') {
ffffffffc0204d70:	fcd57fe3          	bleu	a3,a0,ffffffffc0204d4e <vprintfmt+0x252>
ffffffffc0204d74:	b77d                	j	ffffffffc0204d22 <vprintfmt+0x226>
            if (width < 0)
ffffffffc0204d76:	fffdc693          	not	a3,s11
ffffffffc0204d7a:	96fd                	srai	a3,a3,0x3f
ffffffffc0204d7c:	00ddfdb3          	and	s11,s11,a3
ffffffffc0204d80:	00144603          	lbu	a2,1(s0)
ffffffffc0204d84:	2d81                	sext.w	s11,s11
        switch (ch = *(unsigned char *)fmt ++) {
ffffffffc0204d86:	846a                	mv	s0,s10
ffffffffc0204d88:	b3f5                	j	ffffffffc0204b74 <vprintfmt+0x78>
            putch('%', putdat);
ffffffffc0204d8a:	85a6                	mv	a1,s1
ffffffffc0204d8c:	02500513          	li	a0,37
ffffffffc0204d90:	9902                	jalr	s2
            for (fmt --; fmt[-1] != '%'; fmt --)
ffffffffc0204d92:	fff44703          	lbu	a4,-1(s0)
ffffffffc0204d96:	02500793          	li	a5,37
ffffffffc0204d9a:	8d22                	mv	s10,s0
ffffffffc0204d9c:	d8f70de3          	beq	a4,a5,ffffffffc0204b36 <vprintfmt+0x3a>
ffffffffc0204da0:	02500713          	li	a4,37
ffffffffc0204da4:	1d7d                	addi	s10,s10,-1
ffffffffc0204da6:	fffd4783          	lbu	a5,-1(s10)
ffffffffc0204daa:	fee79de3          	bne	a5,a4,ffffffffc0204da4 <vprintfmt+0x2a8>
ffffffffc0204dae:	b361                	j	ffffffffc0204b36 <vprintfmt+0x3a>
                printfmt(putch, putdat, "error %d", err);
ffffffffc0204db0:	00002617          	auipc	a2,0x2
ffffffffc0204db4:	1e060613          	addi	a2,a2,480 # ffffffffc0206f90 <error_string+0xd8>
ffffffffc0204db8:	85a6                	mv	a1,s1
ffffffffc0204dba:	854a                	mv	a0,s2
ffffffffc0204dbc:	0ac000ef          	jal	ra,ffffffffc0204e68 <printfmt>
ffffffffc0204dc0:	bb9d                	j	ffffffffc0204b36 <vprintfmt+0x3a>
                p = "(null)";
ffffffffc0204dc2:	00002617          	auipc	a2,0x2
ffffffffc0204dc6:	1c660613          	addi	a2,a2,454 # ffffffffc0206f88 <error_string+0xd0>
            if (width > 0 && padc != '-') {
ffffffffc0204dca:	00002417          	auipc	s0,0x2
ffffffffc0204dce:	1bf40413          	addi	s0,s0,447 # ffffffffc0206f89 <error_string+0xd1>
                for (width -= strnlen(p, precision); width > 0; width --) {
ffffffffc0204dd2:	8532                	mv	a0,a2
ffffffffc0204dd4:	85e6                	mv	a1,s9
ffffffffc0204dd6:	e032                	sd	a2,0(sp)
ffffffffc0204dd8:	e43e                	sd	a5,8(sp)
ffffffffc0204dda:	bddff0ef          	jal	ra,ffffffffc02049b6 <strnlen>
ffffffffc0204dde:	40ad8dbb          	subw	s11,s11,a0
ffffffffc0204de2:	6602                	ld	a2,0(sp)
ffffffffc0204de4:	01b05d63          	blez	s11,ffffffffc0204dfe <vprintfmt+0x302>
ffffffffc0204de8:	67a2                	ld	a5,8(sp)
ffffffffc0204dea:	2781                	sext.w	a5,a5
ffffffffc0204dec:	e43e                	sd	a5,8(sp)
                    putch(padc, putdat);
ffffffffc0204dee:	6522                	ld	a0,8(sp)
ffffffffc0204df0:	85a6                	mv	a1,s1
ffffffffc0204df2:	e032                	sd	a2,0(sp)
                for (width -= strnlen(p, precision); width > 0; width --) {
ffffffffc0204df4:	3dfd                	addiw	s11,s11,-1
                    putch(padc, putdat);
ffffffffc0204df6:	9902                	jalr	s2
                for (width -= strnlen(p, precision); width > 0; width --) {
ffffffffc0204df8:	6602                	ld	a2,0(sp)
ffffffffc0204dfa:	fe0d9ae3          	bnez	s11,ffffffffc0204dee <vprintfmt+0x2f2>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0204dfe:	00064783          	lbu	a5,0(a2)
ffffffffc0204e02:	0007851b          	sext.w	a0,a5
ffffffffc0204e06:	e8051be3          	bnez	a0,ffffffffc0204c9c <vprintfmt+0x1a0>
ffffffffc0204e0a:	b335                	j	ffffffffc0204b36 <vprintfmt+0x3a>
        return va_arg(*ap, int);
ffffffffc0204e0c:	000aa403          	lw	s0,0(s5)
ffffffffc0204e10:	bbf1                	j	ffffffffc0204bec <vprintfmt+0xf0>
        return va_arg(*ap, unsigned int);
ffffffffc0204e12:	000ae603          	lwu	a2,0(s5)
ffffffffc0204e16:	46a9                	li	a3,10
ffffffffc0204e18:	8aae                	mv	s5,a1
ffffffffc0204e1a:	bd89                	j	ffffffffc0204c6c <vprintfmt+0x170>
ffffffffc0204e1c:	000ae603          	lwu	a2,0(s5)
ffffffffc0204e20:	46c1                	li	a3,16
ffffffffc0204e22:	8aae                	mv	s5,a1
ffffffffc0204e24:	b5a1                	j	ffffffffc0204c6c <vprintfmt+0x170>
ffffffffc0204e26:	000ae603          	lwu	a2,0(s5)
ffffffffc0204e2a:	46a1                	li	a3,8
ffffffffc0204e2c:	8aae                	mv	s5,a1
ffffffffc0204e2e:	bd3d                	j	ffffffffc0204c6c <vprintfmt+0x170>
                    putch(ch, putdat);
ffffffffc0204e30:	9902                	jalr	s2
ffffffffc0204e32:	b559                	j	ffffffffc0204cb8 <vprintfmt+0x1bc>
                putch('-', putdat);
ffffffffc0204e34:	85a6                	mv	a1,s1
ffffffffc0204e36:	02d00513          	li	a0,45
ffffffffc0204e3a:	e03e                	sd	a5,0(sp)
ffffffffc0204e3c:	9902                	jalr	s2
                num = -(long long)num;
ffffffffc0204e3e:	8ace                	mv	s5,s3
ffffffffc0204e40:	40800633          	neg	a2,s0
ffffffffc0204e44:	46a9                	li	a3,10
ffffffffc0204e46:	6782                	ld	a5,0(sp)
ffffffffc0204e48:	b515                	j	ffffffffc0204c6c <vprintfmt+0x170>
            if (width > 0 && padc != '-') {
ffffffffc0204e4a:	01b05663          	blez	s11,ffffffffc0204e56 <vprintfmt+0x35a>
ffffffffc0204e4e:	02d00693          	li	a3,45
ffffffffc0204e52:	f6d798e3          	bne	a5,a3,ffffffffc0204dc2 <vprintfmt+0x2c6>
ffffffffc0204e56:	00002417          	auipc	s0,0x2
ffffffffc0204e5a:	13340413          	addi	s0,s0,307 # ffffffffc0206f89 <error_string+0xd1>
            for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
ffffffffc0204e5e:	02800513          	li	a0,40
ffffffffc0204e62:	02800793          	li	a5,40
ffffffffc0204e66:	bd1d                	j	ffffffffc0204c9c <vprintfmt+0x1a0>

ffffffffc0204e68 <printfmt>:
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0204e68:	715d                	addi	sp,sp,-80
    va_start(ap, fmt);
ffffffffc0204e6a:	02810313          	addi	t1,sp,40
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0204e6e:	f436                	sd	a3,40(sp)
    vprintfmt(putch, putdat, fmt, ap);
ffffffffc0204e70:	869a                	mv	a3,t1
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
ffffffffc0204e72:	ec06                	sd	ra,24(sp)
ffffffffc0204e74:	f83a                	sd	a4,48(sp)
ffffffffc0204e76:	fc3e                	sd	a5,56(sp)
ffffffffc0204e78:	e0c2                	sd	a6,64(sp)
ffffffffc0204e7a:	e4c6                	sd	a7,72(sp)
    va_start(ap, fmt);
ffffffffc0204e7c:	e41a                	sd	t1,8(sp)
    vprintfmt(putch, putdat, fmt, ap);
ffffffffc0204e7e:	c7fff0ef          	jal	ra,ffffffffc0204afc <vprintfmt>
}
ffffffffc0204e82:	60e2                	ld	ra,24(sp)
ffffffffc0204e84:	6161                	addi	sp,sp,80
ffffffffc0204e86:	8082                	ret

ffffffffc0204e88 <hash32>:
 *
 * High bits are more random, so we use them.
 * */
uint32_t
hash32(uint32_t val, unsigned int bits) {
    uint32_t hash = val * GOLDEN_RATIO_PRIME_32;
ffffffffc0204e88:	9e3707b7          	lui	a5,0x9e370
ffffffffc0204e8c:	2785                	addiw	a5,a5,1
ffffffffc0204e8e:	02f5053b          	mulw	a0,a0,a5
    return (hash >> (32 - bits));
ffffffffc0204e92:	02000793          	li	a5,32
ffffffffc0204e96:	40b785bb          	subw	a1,a5,a1
}
ffffffffc0204e9a:	00b5553b          	srlw	a0,a0,a1
ffffffffc0204e9e:	8082                	ret
